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

Method Initialize

projects/WinDurango.Common/src/Logging.cpp:3–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "Logging.h"
2
3void wd::common::Logging::Initialize()
4{
5 if (!isConstructed)
6 {
7 std::cout << "[WinDurango::Common::Logging.Initialize] - Critical: Logging isn't Constructed\n";
8 return;
9 }
10 try
11 {
12 pFile->open();
13 auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
14 auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(pFile->fullfilepath().string(), true);
15
16 console_sink->set_pattern("[%n] [%H:%M:%S] [thread %t] - %^%l%$: %v");
17 file_sink->set_pattern("[%n] [%H:%M:%S] [thread %t] - %^%l%$: %v");
18
19 std::shared_ptr<spdlog::logger> logg =
20 std::make_shared<spdlog::logger>("WinDurango", spdlog::sinks_init_list{console_sink, file_sink});
21
22 log["WinDurango"] = logg;
23 log["WinDurango"]->set_pattern("[%n] [%H:%M:%S] [thread %t] - %^%l%$: %v");
24 log["WinDurango"]->info("Setting Log File: {}", pFile->fullfilepath().string());
25 log["WinDurango"]->flush_on(spdlog::level::info);
26 isInitialized = true;
27 }
28 catch (const spdlog::spdlog_ex &e)
29 {
30 std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";
31 }
32 catch (const std::exception &e)
33 {
34 std::cout << "[WinDurango::Common::Logging.exception] - Critical: " << e.what() << "\n";
35 }
36 catch (...)
37 {
38 std::cout << "[WinDurango::Common::Logging.(...))] - Critical: Unknown Error\n";
39 }
40}
41
42void wd::common::Logging::AddLogger(std::string codespace)
43{

Callers

nothing calls this directly

Calls 2

fullfilepathMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected