s365b.core.runlog¶
Each job run’s own log, kept in the database for download.
Every log line that carries a run_id (bound on the logger, or bound to
the running task with for_run(), which also covers the Graph client
and other module-level loggers) is copied into that run’s log. Lines are
collected in memory and written in batches by collecting(), which the
worker runs for as long as it works. Lines go to stdout as before.
A run keeps at most MAX_LINES lines; the rest are counted and the
count is noted at the end. Lines whose write failed (the database was
unreachable) are kept and written with the next batch, up to
MAX_PENDING lines in all; past that the oldest are dropped and a
warning goes to stdout. Writing the log never fails a run. Housekeeping
deletes run logs older than its run_log_days setting.
Attributes¶
Functions¶
|
Structlog processor: copy lines that name a run into its log. |
|
Tag every line the current task (and tasks it starts) logs with a run. |
|
Write the queued lines now. |
|
Write the current run's log now that it is done. Never raises. |
|
Collect run logs while the block runs, writing them every few seconds. |
|
One stored line as text: time, level, event, then the other fields. |
Module Contents¶
- s365b.core.runlog.capture(logger: Any, method: str, event_dict: collections.abc.MutableMapping[str, Any]) collections.abc.MutableMapping[str, Any][source]¶
Structlog processor: copy lines that name a run into its log.
- Parameters:
logger – Unused.
method – Unused.
event_dict – The line’s fields; returned unchanged.
- Returns:
event_dict.
- s365b.core.runlog.for_run(run_id: int) None[source]¶
Tag every line the current task (and tasks it starts) logs with a run.
- Parameters:
run_id – The run.
- async s365b.core.runlog.flush(db: s365b.db.session.Database) None[source]¶
Write the queued lines now.
- Parameters:
db – Database.
- async s365b.core.runlog.finish(db: s365b.db.session.Database) None[source]¶
Write the current run’s log now that it is done. Never raises.
The run is the one bound to this task by
for_run(), if any.- Parameters:
db – Database.
- async s365b.core.runlog.collecting(db: s365b.db.session.Database) collections.abc.AsyncIterator[None][source]¶
Collect run logs while the block runs, writing them every few seconds.
- Parameters:
db – Database.
- Yields:
Nothing.