Repository navigation
[Ported] feat(sensor): add an opt-in persistent runtime log - #144
Merged
Merged
Conversation
v314b0i
added this pull request to stack #141
September 27, 2026 22:24
barisozbas
force-pushed
the
port/runtime-log
branch
from
September 28, 2026 07:47
a1cb579 to
f8d9574
Compare
barisozbas
removed this pull request from stack #141
September 29, 2026 11:13
3 of 5 tasks
v314b0i
force-pushed
the
port/runtime-log
branch
from
September 29, 2026 12:20
f8d9574 to
9983a34
Compare
v314b0i
added this pull request to stack #148
September 29, 2026 12:26
barisozbas
approved these changes
Sep 29, 2026
atovkes
approved these changes
Sep 29, 2026
barisozbas
force-pushed
the
port/runtime-log
branch
from
September 29, 2026 13:32
9983a34 to
77c01fc
Compare
Add sensor_log.JsonRecordFormatter, which renders a record as one JSON
object: timestamp, level, component (from the logger name), function,
phase, sensor_version and exception_type, plus the rendered message and
the stack of an attached exception. exception_type also covers the common
logger.warning("... %s", exc) form where the exception is an argument.
include_details=False drops message and stack so records carry no paths
or error text. Nothing uses the formatter yet.
…ogger Add sensor_log.enable_runtime_log(directory) and disable_runtime_log(). When enabled, every sensor log record is also written as JSON lines: WARNING and above to sensor_runtime_errors.jsonl, DEBUG and INFO to sensor_runtime_debug.jsonl, independent of the console level. Each file rotates at 1 MiB with two backups, like diagnostics.jsonl. A runtime log never stops or floods a run: - if the files cannot be opened, one warning is printed and warnings and errors keep going to stderr through the console handlers - a failing write is reported once on stderr instead of once per record - enabling again replaces the previous files
--log-file writes the run's log records to sensor_runtime_errors.jsonl and sensor_runtime_debug.jsonl in the output directory (the same place as diagnostics.jsonl), rotating at 1 MiB with two backups. It is off by default. Records include the message and any traceback, which can contain local file paths and error text; --log-file-content-free omits both and keeps only level, component, function, phase, version and exception type. The files are closed when the run finishes, so repeated in-process calls do not keep writing to an earlier directory.
--log-identity adds the local username and hostname to each --log-file record, so logs collected from many machines can be told apart without relying on file location. It is off by default and requires --log-file. Identity is looked up once per run; an unknown user or host is recorded as null.
…cy options Add a "Runtime log files" README section: file names, level split, rotation, the unwritable-directory fallback, the record fields with an example, and a privacy note covering --log-file-content-free and --log-identity. Remind contributors in CONTRIBUTING.md that log messages can be persisted.
barisozbas
force-pushed
the
port/runtime-log
branch
from
September 29, 2026 13:38
77c01fc to
23f465b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this? (check all applicable)
Related issue: N/A
What changed? (stacked on L4,
port/logger-parsers)feat:JsonRecordFormatterwrites one JSON object per record:timestamp,level,component,function,phase,sensor_versionexception_type(also taken from an exception passed as an argument)message, andstackwhen a traceback is attachedfeat:enable_runtime_log(dir)/disable_runtime_log()attach rotatingsensor_runtime_errors.jsonl(WARNING and above) andsensor_runtime_debug.jsonl(DEBUG/INFO, whatever the console level) files, each 1 MiB × 2.feat:--log-fileenables it under--output-dir, next todiagnostics.jsonl.--log-file-content-freedropsmessageandstack. The files are closed when the run ends.feat: opt-in--log-identityaddsusername/hostname. Both options require--log-file.docs: a README "Runtime log files" section with a privacy note, and a CONTRIBUTING reminder.Why?
diagnostics.jsonlrecords how healthy a run was, using counts and fixed codes. When a source fails, there is currently no persisted record of what failed or where. The runtime log keeps that, off by default, with options to strip content or add identity when logs are collected centrally.How did you test it?
New tests cover:
--log-file, content-free output, identity, and option validationEvery commit passes
pytest tests/ -qandruff check adr_sensor/.Potential risks
--log-file,message/stackcan contain local paths and error text; this is documented, and--log-file-content-freeremoves them. Call sites never log prompts or tool content.