Skip to content

Change the static global logger to be a UI-free logger - #1063

Merged
Mysticial merged 1 commit into
mainfrom
global_file_logger
Jul 11, 2026
Merged

Change the static global logger to be a UI-free logger#1063
Mysticial merged 1 commit into
mainfrom
global_file_logger

Conversation

@Gin890

@Gin890 Gin890 commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

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.

Comment thread Common/Cpp/Logging/FileLogger.h Outdated
Comment thread Common/Cpp/Logging/FileLogger.cpp Outdated
Comment thread Common/Cpp/Logging/GlobalLogger.cpp Outdated

static FileLoggerConfig _global_logger_config;

void initialize_global_logger(FileLoggerConfig config){

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Collaborator Author

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.

@Gin890
Gin890 force-pushed the global_file_logger branch 2 times, most recently from 0100f8a to 4ef80bc Compare January 21, 2026 06:14
// 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",

Copy link
Copy Markdown
Collaborator

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.

@Mysticial

Copy link
Copy Markdown
Collaborator

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, FileLogger will need to be able to operate without a file where it will just keep everything in its history. Then when it's given a filename later, that's when it will flush it out.

@Gin890
Gin890 force-pushed the global_file_logger branch from 4ef80bc to 975c656 Compare March 29, 2026 18:10
@Mysticial Mysticial added the R2 - Medium Risk A PR with changes that are at medium risk of breaking things with moderate impact. label Jun 3, 2026
@Mysticial
Mysticial force-pushed the global_file_logger branch 2 times, most recently from f7bf4ab to 0c20db4 Compare July 11, 2026 03:59
…owLogger.

Separate UI code with file logger code by replacing UI-connected FileWindowLogger with a UI-free FileLogger.
@Mysticial

Copy link
Copy Markdown
Collaborator

Pulled some of this out to: d00cf76

@Mysticial
Mysticial merged commit a1e3e74 into main Jul 11, 2026
14 checks passed
@pifopi
pifopi deleted the global_file_logger branch July 19, 2026 09:20
Developer-Butters pushed a commit to Developer-Butters/Arduino-Source that referenced this pull request Jul 28, 2026
…owLogger. (PokemonAutomation#1063)

Separate UI code with file logger code by replacing UI-connected FileWindowLogger with a UI-free FileLogger.

Co-authored-by: Alexander Yee <a-yee@u.northwestern.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R2 - Medium Risk A PR with changes that are at medium risk of breaking things with moderate impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants