-
Notifications
You must be signed in to change notification settings - Fork 87
Change the static global logger to be a UI-free logger #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.