Change the static global logger to be a UI-free logger#1063
Change the static global logger to be a UI-free logger#1063
Conversation
Common/Cpp/Logging/GlobalLogger.cpp
Outdated
|
|
||
| static FileLoggerConfig _global_logger_config; | ||
|
|
||
| void initialize_global_logger(FileLoggerConfig config){ |
There was a problem hiding this comment.
We need to be careful here that nothing calls the logger during static init.
Alternatively, you can make the entire logger lazy static init.
There was a problem hiding this comment.
How can you do that? The logger object is already lazy static init but it needs to be set with a proper logger config, which I can only implement in this PR by calling initialize_global_logger() at start of main() to initialize a static config struct before any logger calls.
3824e06 to
0100f8a
Compare
0100f8a to
4ef80bc
Compare
| // correctly you need to define `QApplication` before `make_global_config()` is called. | ||
| FileLoggerConfig make_global_config(){ | ||
| return FileLoggerConfig{ | ||
| .file_path = USER_FILE_PATH() + QCoreApplication::applicationName().toStdString() + ".log", |
There was a problem hiding this comment.
You cannot QCoreApplication::applicationName() before initializing Qt from main.
|
Reposting my Discord comment here: I think we need a way to defer the file saving until later. We won't know the filename until we enter main() since it comes from the args. IOW, |
The static global logger is now a FileLogger. The old GUI-dependent logger, FileWindowLogger is removed. Each LogWindow is connected directly to the global FileLogger.