|
12 | 12 | #pragma once |
13 | 13 |
|
14 | 14 | #include "spdlog/logger.h" |
| 15 | +#include <fmt/core.h> |
| 16 | +#include <spdlog/fmt/ostr.h> |
15 | 17 |
|
16 | 18 | class EventuallyPersistentEngine; |
17 | 19 |
|
@@ -296,4 +298,98 @@ std::shared_ptr<BucketLogger>& getGlobalBucketLogger(); |
296 | 298 | #define EP_LOG_CRITICAL_RAW(msg) \ |
297 | 299 | EP_LOG_RAW(spdlog::level::level_enum::critical, msg) |
298 | 300 |
|
299 | | -#include "bucket_logger_impl.h" |
| 301 | +template <typename S, typename... Args> |
| 302 | +void BucketLogger::log(spdlog::level::level_enum lvl, |
| 303 | + const S& fmt, |
| 304 | + Args&&... args) { |
| 305 | + if (!should_log(lvl)) { |
| 306 | + return; |
| 307 | + } |
| 308 | + |
| 309 | +#if FMT_VERSION < 100000 |
| 310 | + logInner(lvl, fmt, fmt::make_args_checked<Args...>(fmt, args...)); |
| 311 | +#else |
| 312 | + logInner(lvl, fmt, fmt::make_format_args(args...)); |
| 313 | +#endif |
| 314 | +} |
| 315 | + |
| 316 | +template <typename... Args> |
| 317 | +void BucketLogger::log(spdlog::level::level_enum lvl, const char* msg) { |
| 318 | + if (!should_log(lvl)) { |
| 319 | + return; |
| 320 | + } |
| 321 | + logInner(lvl, msg, {}); |
| 322 | +} |
| 323 | + |
| 324 | +template <typename T> |
| 325 | +void BucketLogger::log(spdlog::level::level_enum lvl, const T& msg) { |
| 326 | + if (!should_log(lvl)) { |
| 327 | + return; |
| 328 | + } |
| 329 | + |
| 330 | +#if FMT_VERSION < 100000 |
| 331 | + logInner(lvl, "{}", fmt::make_args_checked<T>("{}", msg)); |
| 332 | +#else |
| 333 | + logInner(lvl, "{}", fmt::make_format_args(msg)); |
| 334 | +#endif |
| 335 | +} |
| 336 | + |
| 337 | +template <typename... Args> |
| 338 | +void BucketLogger::trace(const char* fmt, const Args&... args) { |
| 339 | + log(spdlog::level::trace, fmt, args...); |
| 340 | +} |
| 341 | + |
| 342 | +template <typename... Args> |
| 343 | +void BucketLogger::debug(const char* fmt, const Args&... args) { |
| 344 | + log(spdlog::level::debug, fmt, args...); |
| 345 | +} |
| 346 | + |
| 347 | +template <typename... Args> |
| 348 | +void BucketLogger::info(const char* fmt, const Args&... args) { |
| 349 | + log(spdlog::level::info, fmt, args...); |
| 350 | +} |
| 351 | + |
| 352 | +template <typename... Args> |
| 353 | +void BucketLogger::warn(const char* fmt, const Args&... args) { |
| 354 | + log(spdlog::level::warn, fmt, args...); |
| 355 | +} |
| 356 | + |
| 357 | +template <typename... Args> |
| 358 | +void BucketLogger::error(const char* fmt, const Args&... args) { |
| 359 | + log(spdlog::level::err, fmt, args...); |
| 360 | +} |
| 361 | + |
| 362 | +template <typename... Args> |
| 363 | +void BucketLogger::critical(const char* fmt, const Args&... args) { |
| 364 | + log(spdlog::level::critical, fmt, args...); |
| 365 | +} |
| 366 | + |
| 367 | +template <typename T> |
| 368 | +void BucketLogger::trace(const T& msg) { |
| 369 | + log(spdlog::level::trace, msg); |
| 370 | +} |
| 371 | + |
| 372 | +template <typename T> |
| 373 | +void BucketLogger::debug(const T& msg) { |
| 374 | + log(spdlog::level::debug, msg); |
| 375 | +} |
| 376 | + |
| 377 | +template <typename T> |
| 378 | +void BucketLogger::info(const T& msg) { |
| 379 | + log(spdlog::level::info, msg); |
| 380 | +} |
| 381 | + |
| 382 | +template <typename T> |
| 383 | +void BucketLogger::warn(const T& msg) { |
| 384 | + log(spdlog::level::warn, msg); |
| 385 | +} |
| 386 | + |
| 387 | +template <typename T> |
| 388 | +void BucketLogger::error(const T& msg) { |
| 389 | + log(spdlog::level::err, msg); |
| 390 | +} |
| 391 | + |
| 392 | +template <typename T> |
| 393 | +void BucketLogger::critical(const T& msg) { |
| 394 | + log(spdlog::level::critical, msg); |
| 395 | +} |
0 commit comments