mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-27 07:59:03 +08:00
166843ff3a
Some checks failed
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[asan:ON build_type:Debug … (push) Has been cancelled
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[build_type:Debug compiler… (push) Has been cancelled
linux / ${{ matrix.config.compiler}} ${{ matrix.config.version }} (C++${{ matrix.config.cppstd }} ${{ matrix.config.build_type }} ${{ matrix.config.asan == 'ON' && 'ASAN' || '' }}${{ matrix.config.tsan == 'ON' && 'TSAN' || '' }}) (map[build_type:Release compil… (push) Has been cancelled
macos / macOS Clang (C++17, Release) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:OFF BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:OFF BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:20 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build (map[BUILD_EXAMPLE:ON BUILD_SHARED:OFF BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 17 2022]) (push) Has been cancelled
windows / build_2019 (map[BUILD_EXAMPLE:ON BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:17 FATAL_ERRORS:ON GENERATOR:Visual Studio 16 2019]) (push) Has been cancelled
windows / build_2019 (map[BUILD_EXAMPLE:ON BUILD_SHARED:ON BUILD_TYPE:Release CXX_STANDARD:20 FATAL_ERRORS:ON GENERATOR:Visual Studio 16 2019]) (push) Has been cancelled
Removed registry
58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
#include <cassert>
|
|
#include <memory>
|
|
|
|
#include "spdlog/common.h"
|
|
#include "spdlog/logger.h"
|
|
#include "spdlog/pattern_formatter.h"
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
|
|
namespace spdlog {
|
|
|
|
static std::shared_ptr s_context =
|
|
#ifndef SPDLOG_DISABLE_GLOBAL_LOGGER
|
|
std::make_unique<details::context>(std::make_unique<logger>(std::string(), std::make_unique<sinks::stdout_color_sink_mt>()));
|
|
#else
|
|
std::make_unique<details::context>(); // empty context
|
|
#endif
|
|
|
|
void set_context(std::shared_ptr<details::context> context) { s_context = std::move(context); }
|
|
|
|
std::shared_ptr<details::context> context() { return s_context; }
|
|
|
|
const std::shared_ptr<details::context> &context_ref() { return s_context; }
|
|
|
|
std::shared_ptr<logger> global_logger() { return context_ref()->global_logger(); }
|
|
|
|
void set_global_logger(std::shared_ptr<logger> global_logger) { context()->set_logger(std::move(global_logger)); }
|
|
|
|
logger *global_logger_raw() noexcept {
|
|
auto *rv = context_ref()->global_logger_raw();
|
|
assert(rv != nullptr);
|
|
return rv;
|
|
}
|
|
|
|
void set_formatter(std::unique_ptr<formatter> formatter) { global_logger()->set_formatter(std::move(formatter)); }
|
|
|
|
void set_pattern(std::string pattern, pattern_time_type time_type) {
|
|
set_formatter(std::make_unique<pattern_formatter>(std::move(pattern), time_type));
|
|
}
|
|
|
|
level get_level() { return global_logger()->log_level(); }
|
|
|
|
bool should_log(level level) { return global_logger()->should_log(level); }
|
|
|
|
void set_level(level level) { global_logger()->set_level(level); }
|
|
|
|
void flush_on(level level) { global_logger()->flush_on(level); }
|
|
|
|
void set_error_handler(void (*handler)(const std::string &msg)) { global_logger()->set_error_handler(handler); }
|
|
|
|
void shutdown() { s_context.reset(); }
|
|
|
|
} // namespace spdlog
|