|
17 | 17 | #include "../CommonUtilities/str/String.h" |
18 | 18 | #include "../CommonUtilities/Exception.h" |
19 | 19 | #include "CliOptions.h" |
| 20 | +#include "Registry.h" |
20 | 21 |
|
21 | 22 | namespace pmon::util::log |
22 | 23 | { |
@@ -63,23 +64,25 @@ namespace logsetup |
63 | 64 | void ConfigureLogging(bool asApp) noexcept |
64 | 65 | { |
65 | 66 | try { |
66 | | - // shortcut for command line |
| 67 | + // shortcuts for command line and registry |
67 | 68 | const auto& opt = clio::Options::Get(); |
| 69 | + const auto& reg = Reg::Get(); |
68 | 70 | // get the channel |
69 | 71 | auto pChannel = GetDefaultChannel(); |
70 | 72 | // configure logging based on command line |
71 | | - if (opt.logLevel) { |
72 | | - GlobalPolicy::Get().SetLogLevel(*opt.logLevel); |
| 73 | + if (opt.logLevel || reg.logLevel.Exists()) { |
| 74 | + GlobalPolicy::Get().SetLogLevel(opt.logLevel ? *opt.logLevel : reg.logLevel); |
73 | 75 | } |
74 | 76 | if (!opt.enableStdioLog) { |
75 | 77 | pChannel->AttachComponent({}, "drv:std"); |
76 | 78 | } |
77 | 79 | if (!opt.enableDebuggerLog) { |
78 | 80 | pChannel->AttachComponent({}, "drv:dbg"); |
79 | 81 | } |
80 | | - if (opt.logDir) { |
| 82 | + if (opt.logDir || reg.logDir.Exists()) { |
| 83 | + const auto dir = opt.logDir ? *opt.logDir : reg.logDir; |
81 | 84 | const std::chrono::zoned_time now{ std::chrono::current_zone(), std::chrono::system_clock::now() }; |
82 | | - auto fullPath = std::format("{0}\\pmsvc-log-{1:%y}{1:%m}{1:%d}-{1:%H}{1:%M}{1:%OS}.txt", *opt.logDir, now); |
| 85 | + auto fullPath = std::format("{0}\\pmsvc-log-{1:%y}{1:%m}{1:%d}-{1:%H}{1:%M}{1:%OS}.txt", dir, now); |
83 | 86 | pChannel->AttachComponent(std::make_shared<BasicFileDriver>( std::make_shared<TextFormatter>(), |
84 | 87 | std::make_shared<SimpleFileStrategy>(fullPath)), "drv:file"); |
85 | 88 | } |
|
0 commit comments