MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / Initialize

Method Initialize

ProgramLog/log.cpp:87–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void Log::Initialize(const std::optional<std::filesystem::path> &storageFolder)
88{
89 auto expected = InitStatus::NotInitialized;
90 if (s_LogInitStatus.compare_exchange_strong(expected, InitStatus::Initializing))
91 {
92 auto defaultLogger = std::make_shared<spdlog::logger>("", std::make_shared<spdlog::sinks::windebug_sink_st>());
93
94 if (auto path = GetPath(storageFolder); !path.empty())
95 {
96 auto fileLog = std::make_shared<lazy_file_sink_mt>(std::move(path));
97 fileLog->set_level(Config::DEFAULT_LOG_VERBOSITY);
98 s_LogSink = fileLog;
99
100 defaultLogger->sinks().push_back(std::move(fileLog));
101 }
102
103 spdlog::set_formatter(std::make_unique<spdlog::pattern_formatter>(spdlog::pattern_time_type::utc));
104 spdlog::set_level(spdlog::level::trace);
105 spdlog::flush_on(spdlog::level::off);
106 spdlog::set_error_handler(LogErrorHandler);
107 spdlog::initialize_logger(defaultLogger);
108 spdlog::set_default_logger(std::move(defaultLogger));
109
110 s_LogInitStatus = InitStatus::Initialized;
111 }
112 else
113 {
114 throw std::logic_error("Log::Initialize should only be called once");
115 }
116}

Callers 1

XamlPageHostMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected