Skip to content

Update to PR #727 better better multithread logging#847

Merged
miredirex merged 3 commits intotiltedphoques:devfrom
rfortier:tweak/Update-PR-727-better-better-logging
Feb 15, 2026
Merged

Update to PR #727 better better multithread logging#847
miredirex merged 3 commits intotiltedphoques:devfrom
rfortier:tweak/Update-PR-727-better-better-logging

Conversation

@rfortier
Copy link
Copy Markdown
Contributor

@rfortier rfortier commented Jan 4, 2026

Follow-on to PR #727

In addition to console window, make sure the file logs also contain the millisecond and thread ID.

Flushes server console log every 2 seconds.

Flushes client log on every log line at [info] or greater. This is to make sure that crash logs are up-to-date (or reasonably close).

Copy link
Copy Markdown
Collaborator

@miredirex miredirex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flushes server console log every 2 seconds.

Could it cause lag? Or does it happen in background?

This is to make sure that crash logs are up-to-date (or reasonably close).

spdlog::critical(__FUNCTION__ ": coredump created -> flush logs.");
}
}
spdlog::default_logger()->flush();

I think we already flush logs on any crash

@rfortier
Copy link
Copy Markdown
Contributor Author

rfortier commented Jan 4, 2026

Flushes server console log every 2 seconds.

Could it cause lag? Or does it happen in background?

It won't cause lag. Doesn't for the console window, which flushes every line. For flush_every(), flushing is done on an async thread.

Without this the console logfile is only flushed when it fills up a page, which is 8 or 16KB (so, could be very out-of-date). And, if you finish a session and kill the console window, it is never flushed.

spdlog::critical(__FUNCTION__ ": coredump created -> flush logs.");
}
}
spdlog::default_logger()->flush();

I think we already flush logs on any crash

Well, yeah. I'm pretty sure I put that line there when I made crashloggers work.
It doesn't work, though. Probably because it is flushing the wrong logger, I didn't know as much at the time. Or, because we're crashing and the logger is borked. Keeping the log reasonably up-to-date should work around the issue regardless.

But I will take a look and see which stream is the file logger; fixing that flush would be nice. The tweak as-is is still needed to flush the file, though, or things that are tailing/watching the log file won't be up to date.

@rfortier rfortier force-pushed the tweak/Update-PR-727-better-better-logging branch from 2d666cf to 4b7708f Compare January 14, 2026 21:24
@rfortier
Copy link
Copy Markdown
Contributor Author

It's been stable. Added one last tweak (date, helps us reject people sending wrong logs)

@rfortier rfortier marked this pull request as ready for review January 14, 2026 21:25
@rfortier rfortier force-pushed the tweak/Update-PR-727-better-better-logging branch from 4b7708f to 2cb5366 Compare January 14, 2026 22:14
@miredirex
Copy link
Copy Markdown
Collaborator

Suggestion: "%^[%Y-%m-%d %H:%M:%S.%e] for the log files, but not for the console output. This should be possible with spdlog

In addition to console window, make sure file logs contain the millisecond and thread ID.

Flushes server console log every 2 seconds.

Flushes client log every 1s. Will need to separately determine why the flush of the log when crashing doesn't work. But this is good-enough for tail'ing the client log file, and somewhat lower overhead then flushing on every line.

Added date to timestamp, which will help us detect when someone sends us the wrong log for a bug.
@rfortier rfortier force-pushed the tweak/Update-PR-727-better-better-logging branch from 2cb5366 to c4d91df Compare February 7, 2026 17:49
@rfortier
Copy link
Copy Markdown
Contributor Author

rfortier commented Feb 7, 2026

Updated to flush_on( 1 second ) instead. Good enough for an active tail -f on the log file, and infinitesimal overhead.

Will need to separately figure out why the flush in the crash path is not working. The correct sink is being flushed, but the log file is not being updated.

@miredirex miredirex merged commit cef4ad5 into tiltedphoques:dev Feb 15, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants