mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
use global_logger_raw from spdlog.h
This commit is contained in:
parent
f9e59be886
commit
3e753710f4
@ -77,20 +77,26 @@ SPDLOG_API std::shared_ptr<logger> global_logger();
|
|||||||
// Set the global logger. (for example, to replace the global logger with a custom logger)
|
// Set the global logger. (for example, to replace the global logger with a custom logger)
|
||||||
SPDLOG_API void set_global_logger(std::shared_ptr<logger> global_logger);
|
SPDLOG_API void set_global_logger(std::shared_ptr<logger> global_logger);
|
||||||
|
|
||||||
|
// Return the global logger raw pointer.
|
||||||
|
// To be used directly by the spdlog default API (e.g. spdlog::info)
|
||||||
|
// This make the default API faster, but cannot be used concurrently with set_global_logger().
|
||||||
|
// e.g do not call set_global_logger() from one thread while calling spdlog::info() from another.
|
||||||
|
SPDLOG_API logger *global_logger_raw() noexcept;
|
||||||
|
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void log(source_loc source, level lvl, format_string_t<Args...> fmt, Args &&...args) {
|
void log(source_loc source, level lvl, format_string_t<Args...> fmt, Args &&...args) {
|
||||||
global_logger()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
global_logger_raw()->log(source, lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void log(level lvl, format_string_t<Args...> fmt, Args &&...args) {
|
void log(level lvl, format_string_t<Args...> fmt, Args &&...args) {
|
||||||
global_logger()->log(lvl, fmt, std::forward<Args>(args)...);
|
global_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void log(level lvl, std::string_view msg) { global_logger()->log(lvl, msg); }
|
inline void log(level lvl, std::string_view msg) { global_logger_raw()->log(lvl, msg); }
|
||||||
|
|
||||||
inline void log(source_loc loc, level lvl, std::string_view msg) { global_logger()->log(loc, lvl, msg); }
|
inline void log(source_loc loc, level lvl, std::string_view msg) { global_logger_raw()->log(loc, lvl, msg); }
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void trace(format_string_t<Args...> fmt, Args &&...args) {
|
void trace(format_string_t<Args...> fmt, Args &&...args) {
|
||||||
|
@ -26,6 +26,8 @@ void set_global_logger(std::shared_ptr<logger> global_logger) {
|
|||||||
context()->set_logger(std::move(global_logger));
|
context()->set_logger(std::move(global_logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger *global_logger_raw() noexcept { return context_ref()->global_logger_raw(); }
|
||||||
|
|
||||||
void set_formatter(std::unique_ptr<formatter> formatter) {
|
void set_formatter(std::unique_ptr<formatter> formatter) {
|
||||||
global_logger()->set_formatter(std::move(formatter));
|
global_logger()->set_formatter(std::move(formatter));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user