MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / ConfigureLogging

Function ConfigureLogging

IntelPresentMon/SampleClient/LogSetup.cpp:61–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 using namespace pmon::util::log;
60
61 void ConfigureLogging() noexcept
62 {
63 try {
64 // get the channel to work on it
65 auto pChan = GetDefaultChannel();
66 // connect dll channel and id table to exe, get access to global settings in dll
67 const auto getters = pmLinkLogging_(pChan, []() -> IdentificationTable&
68 { return IdentificationTable::Get_(); });
69 // shortcut for command line
70 const auto& opt = clio::Options::Get();
71 // configure logging based on command line
72 if (opt.logFolder || opt.logNamePid) {
73 const auto logFileName = opt.logNamePid ?
74 std::format("sample-client-{}.txt", GetCurrentProcessId()) :
75 "sample - client.txt"s;
76 const auto logFileFolder = opt.logFolder ? *opt.logFolder : "."s;
77 const auto logFilePath = std::format("{}\\{}", logFileFolder, logFileName);
78 pChan->AttachComponent(std::make_shared<BasicFileDriver>(
79 std::make_shared<TextFormatter>(),
80 std::make_shared<SimpleFileStrategy>(logFilePath)), "drv:file");
81 }
82 if (opt.logLevel) {
83 GlobalPolicy::Get().SetLogLevel(*opt.logLevel);
84 getters.getGlobalPolicy().SetLogLevel(*opt.logLevel);
85 }
86 if (opt.logVerboseModules) {
87 for (auto mod : *opt.logVerboseModules) {
88 GlobalPolicy::Get().ActivateVerboseModule(mod);
89 getters.getGlobalPolicy().ActivateVerboseModule(mod);
90 }
91 }
92 if (opt.logTraceLevel) {
93 GlobalPolicy::Get().SetTraceLevel(*opt.logTraceLevel);
94 getters.getGlobalPolicy().SetTraceLevel(*opt.logTraceLevel);
95 }
96 if (opt.logTraceExceptions) {
97 GlobalPolicy::Get().SetExceptionTrace(*opt.logTraceExceptions);
98 GlobalPolicy::Get().SetSehTracing(*opt.logTraceExceptions);
99 getters.getGlobalPolicy().SetExceptionTrace(*opt.logTraceExceptions);
100 getters.getGlobalPolicy().SetSehTracing(*opt.logTraceExceptions);
101 }
102 if (opt.logDenyList) {
103 pmquell(LineTable::IngestList(*opt.logDenyList, true))
104 pmquell(getters.getLineTable().IngestList_(*opt.logDenyList, true))
105 }
106 else if (opt.logAllowList) {
107 pmquell(LineTable::IngestList(*opt.logAllowList, false))
108 pmquell(getters.getLineTable().IngestList_(*opt.logAllowList, false))
109 }
110 }
111 catch (...) {}
112 }
113 LogChannelManager::LogChannelManager() noexcept
114 {
115 InstallSehTranslator();

Callers 2

mainFunction · 0.70
WinMainFunction · 0.50

Calls 8

SetLogLevelMethod · 0.80
ActivateVerboseModuleMethod · 0.80
SetTraceLevelMethod · 0.80
SetExceptionTraceMethod · 0.80
SetSehTracingMethod · 0.80
IngestList_Method · 0.80
GetDefaultChannelFunction · 0.70
AttachComponentMethod · 0.45

Tested by

no test coverage detected