Skip to content

Replay pre-init config warnings into the night log (follow-up to #924) - #965

Open
dvida wants to merge 2 commits into
prereleasefrom
night-log-early-warnings
Open

Replay pre-init config warnings into the night log (follow-up to #924)#965
dvida wants to merge 2 commits into
prereleasefrom
night-log-early-warnings

Conversation

@dvida

@dvida dvida commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #924 (merged), same theme — make night-time problems visible in the uploaded night log. #924 covered night product failures; this round closes the gap it left and tidies a few related spots.

1. Replay pre-init config warnings into the night log

Config parsing runs before initLogging in every entry point, so config-validation warnings — clamped FPS, bad binning factor/method, jpg/png quality ranges, FOV check, band ratios, "upload disabled on the default station code" — only ever hit the console and never the uploaded night log, which is exactly where you'd look to answer "did my station configure correctly?".

Fix: a small EarlyRecordBuffer on the root logger (RMS/Logger.py) collects WARNING+ records emitted before logging is up; initLogging drains it and replays them into the night log with their original timestamps (InRmsFilter still drops non-RMS noise on replay).

ConfigReader.parse() installs the buffer as its first step — the single funnel every config load passes through — so it rides along with the parser and needs no per-entry-point wiring. installEarlyLogBuffer() is idempotent and self-managing: a no-op once real logging is up (a QueueHandler on the root logger, main process or child), so a re-parse after startup can't leave an undrained buffer, and a bare import RMS.ConfigReader no longer mutates the caller's root logger.

2. Tidy night-product logging (Reprocess.py)

Collapse the night-product exception handlers onto log.warning(..., exc_info=True) instead of hand-formatting the traceback into two warning lines, and route the last FT-archiving print() calls through logging so they land in the night log with a level and timestamp.

3. FRbinViewer key legend

Default the on-screen legend to off so it never covers the image unless asked for (toggle with h); print the key banner to the console when a file is opened instead.

4. README

Drop RMS.ClearSkyDetector from the runnable-module list — it has no CLI entry point.

Testing

  • installEarlyLogBuffer: verified a bare import RMS.ConfigReader installs no buffer; the buffer captures WARNING+ and ignores INFO; _drainEarlyLogBuffer returns the records; and it no-ops once a QueueHandler is on the root logger.
  • All changed modules compile; ConfigReader/Logger import clean.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b78e75de20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread RMS/Logger.py
Comment on lines +606 to +607
for record in early_records:
main_logger.handle(record)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid replaying buffered warnings to the console

When configuration parsing emits a WARNING+ and console_level permits it (the default is INFO), _default_handler has already printed the record to stderr. Replaying it through the root queue here sends the same record to the listener's console handler as well as its file handler, so every affected startup displays each configuration warning twice. Route replayed records only to the file sink, or mark and filter them from the listener's console handler.

Useful? React with 👍 / 👎.

dvida and others added 2 commits August 11, 2026 10:37
Config parsing runs before initLogging in every entry point, so validation
warnings (clamped FPS, bad binning factor/method, jpg/png quality ranges,
FOV check, band ratios, upload disabled on the default station code) only
ever reached the console and never the uploaded night log - the very log
someone reads to answer "did my station configure correctly?".

Add an EarlyRecordBuffer to Logger: a small capped handler on the root
logger that collects WARNING+ records emitted before logging is up.
initLogging drains it and replays the records into the night log with
their original timestamps (InRmsFilter still drops non-RMS noise on
replay). ConfigReader.parse() installs the buffer as its first step - the
single funnel every config load passes through - so this rides along with
the parser and needs no per-entry-point wiring.

installEarlyLogBuffer is idempotent and self-managing: a no-op once real
logging is initialized (a QueueHandler is present on the root logger, in
the main process or a child), so a config re-parse after startup cannot
leave an undrained buffer, and a bare `import RMS.ConfigReader` no longer
mutates the caller's root logger.

The replayed records are marked and dropped by the listener's console
handler (kept by the file handler), so a config warning already printed to
the console before logging came up is not shown a second time on replay.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reprocess: collapse the night-product exception handlers onto
log.warning(..., exc_info=True) instead of hand-formatting the traceback
into two warning lines, and route the last FT-archiving print() calls
through logging so they land in the night log with a level and timestamp.

FRbinViewer: default the on-screen key legend to off so it never covers
the image unless asked for (toggle with 'h'), and print the key banner to
the console when a file is opened instead.

README: drop RMS.ClearSkyDetector from the runnable-module list (it has no
CLI entry point).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dvida
dvida force-pushed the night-log-early-warnings branch from b78e75d to fff8601 Compare August 11, 2026 14:37
@dvida

dvida commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Good catch — fixed in c52465b. The double print was real: _default_handler prints the config warning to stderr before logging is up, and the replay then went through the queue to both the listener's file and console handlers, so the console showed it twice.

Fix: replayed records are now tagged (replayed_from_early_buffer), and a _SuppressReplayedOnConsole filter on the listener's console handler drops them. The file handler still receives them, so the night log keeps the warning exactly once, and the console shows it once (the pre-init stderr print). Verified the filter drops tagged records and passes normal ones.

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