diff options
Diffstat (limited to 'include/boltdbg/util')
| -rw-r--r-- | include/boltdbg/util/logger.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/boltdbg/util/logger.h b/include/boltdbg/util/logger.h new file mode 100644 index 0000000..554f2c7 --- /dev/null +++ b/include/boltdbg/util/logger.h @@ -0,0 +1,26 @@ +#ifndef BOLTDBG_UTIL_LOGGER_H_ +#define BOLTDBG_UTIL_LOGGER_H_ + +/* + * Global spdlog accessor for boltdbg. + * + * Use Log::get() anywhere to obtain the shared logger. + */ + +#include <memory> +#include <spdlog/spdlog.h> + +namespace Log { // NOTE: capital 'L' to avoid collision with C math 'log' + // Return a reference to a shared_ptr logger initialized on first use. + std::shared_ptr<spdlog::logger>& get(); +} + +// Handy logger macros (use Log with capital L) +#define LOG_TRACE(...) ::Log::get()->trace(__VA_ARGS__) +#define LOG_DEBUG(...) ::Log::get()->debug(__VA_ARGS__) +#define LOG_INFO(...) ::Log::get()->info(__VA_ARGS__) +#define LOG_WARN(...) ::Log::get()->warn(__VA_ARGS__) +#define LOG_ERROR(...) ::Log::get()->error(__VA_ARGS__) +#define LOG_CRITICAL(...) ::Log::get()->critical(__VA_ARGS__) + +#endif // BOLTDBG_UTIL_LOGGER_H_ |
