Skip to main content
Redacting readers over the structured log files. Reads the JSON log file bioptimus.observability.logging writes and returns its entries as mappings, anonymized by default so the result is suitable to export in a support bundle or the server /diagnostics response. This redaction is best-effort, not a guarantee (see bioptimus.observability.anonymize). Two views are provided: read_recent_logs tails the active file, and read_usage_records selects model-request usage entries across the active file and all of its rotations. Both resolve the log file exactly as bioptimus.observability.logging.configure_logging does and reuse the same per-field anonymization policy as emission-time redaction.

USAGE_EVENT

Structured-log event slug identifying a model-request usage record. The API server emits it on every inference, embedding, and metadata call, so read_usage_records can select these entries for usage reporting.

read_recent_logs

Reads the most recent entries from the active log file. Resolves the log file the same way configure_logging does: from log_file when given, otherwise the BIOPTIMUS_LOG_FILE environment variable, otherwise default_log_file. Reads up to the last max_entries lines, parses each structured JSON line into a mapping, and (by default) anonymizes it exactly as it is anonymized at emission. A line that is not JSON is wrapped as a {"message": ...} entry with embedded slide paths and user names scrubbed. Only the active log file is read; rotated files are left to the support bundle, which archives the full history. When file logging is disabled (BIOPTIMUS_LOG_FILE set empty) or the file does not yet exist, an empty list is returned.
Path to the log file to read. When omitted, the BIOPTIMUS_LOG_FILE environment variable supplies it and, if that is unset, default_log_file.
Maximum number of trailing entries to return.
When True (the default), redacts PII from each entry so the result is safe to export.
Returns: Recent log entries, oldest first, each as a mapping.

read_usage_records

Reads every model-request usage record from the active and rotated logs. Selects the structured log entries whose event is USAGE_EVENT across the active log file and all of its rotations, so the result is the complete usage history rather than the recent tail read_recent_logs returns. Records are returned oldest first: the rotated files (ordered by their date suffix) precede the active file, and entries within each file keep their append order. Each record is anonymized the same way it was at emission unless anonymize is False. The log file is resolved exactly as by configure_logging: from log_file when given, otherwise the BIOPTIMUS_LOG_FILE environment variable, otherwise default_log_file. When file logging is disabled (BIOPTIMUS_LOG_FILE set empty) or no log file exists yet, an empty list is returned.
Path to the active log file. When omitted, the BIOPTIMUS_LOG_FILE environment variable supplies it and, if that is unset, default_log_file. Rotated files sharing the same base name are read automatically.
When True (the default), redacts PII from each record so the result is safe to export.
Returns: Every usage record, oldest first, each as a mapping.