Skip to content

feat: file logging and configurable minimum log level#6

Open
jpnurmi wants to merge 1 commit intogetsentryfrom
jpnurmi/feat/log-file
Open

feat: file logging and configurable minimum log level#6
jpnurmi wants to merge 1 commit intogetsentryfrom
jpnurmi/feat/log-file

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Apr 17, 2026

Required for (and built by):

Two additions to mini_chromium's logging:

  1. LOG_TO_FILE destination. Implements the previously stubbed LOG_TO_FILE destination and adds a simplified base::OpenFile() helper (after upstream Chromium's helper of the same name). Callers pass the path via LoggingSettings::log_file_path. The file is opened lazily for appending on the first emitted message and held by a std::unique_ptr<FILE> with a silent closer, so an fclose failure during static destruction cannot re-enter Flush() and deadlock on the file lock. File state (lock, path, handle, and an enabled flag) is grouped in a file-scope LogFile struct; an empty path or a failed open is handled by clearing enabled, so a transient open failure cannot clobber a concurrent InitLogging(). Concurrent LOG calls are serialized with a base::Lock.

  2. Configurable minimum log level. Replaces the hardcoded GetMinLogLevel() with a runtime-configurable value. Adds SetMinLogLevel() and a min_log_level field on LoggingSettings (applied by InitLogging). Default remains LOG_INFO, so existing callers are unaffected.

g_logging_destination and g_min_log_level are std::atomic so reads on the LOG hot path don't need the file lock and writes from InitLogging / SetMinLogLevel don't race concurrent readers.

See also:

Comment thread base/logging.h
Comment thread base/logging.cc
Comment thread base/logging.cc Outdated
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 82b99ca. Configure here.

Comment thread base/logging.cc Outdated
Comment thread base/logging.cc
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/log-file branch from 82b99ca to edd9975 Compare April 17, 2026 20:13
Comment thread base/logging.cc Outdated
Two additions to mini_chromium's logging:

1. LOG_TO_FILE destination. Implements the previously stubbed
   LOG_TO_FILE destination and adds a simplified base::OpenFile()
   helper (after upstream Chromium's helper of the same name).
   Callers pass the path via LoggingSettings::log_file_path. The
   file is opened lazily for appending on the first emitted message
   and held by a std::unique_ptr<FILE> with a silent closer so an
   fclose failure during static destruction cannot re-enter Flush()
   and deadlock on the file lock. File state (lock, path, handle,
   and an `enabled` flag) is grouped in a file-scope LogFile struct;
   an empty path or a failed open is handled by clearing `enabled`,
   so a transient open failure cannot clobber a concurrent
   InitLogging(). Concurrent LOG calls are serialized with a
   base::Lock.

2. Configurable minimum log level. Replaces the hardcoded
   GetMinLogLevel() with a runtime-configurable value. Adds
   SetMinLogLevel() and a min_log_level field on LoggingSettings
   (applied by InitLogging). Default remains LOG_INFO, so existing
   callers are unaffected.

g_logging_destination and g_min_log_level are std::atomic so reads
on the LOG hot path don't need the file lock and writes from
InitLogging / SetMinLogLevel don't race concurrent readers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant