Skip to main content
Logging settings, setup and the process log-redaction registries. Side-effect-free on import: the consumer calls setup_logging(...) and install_record_redaction(...) explicitly (e.g. at app startup), and a feature registers its own redaction patterns — importing this package configures nothing.

REDACTOR_FAILED

tai42_kit.logging.redaction.REDACTOR_FAILED

TRANSPORT_LOGGERS

tai42_kit.logging.redaction.TRANSPORT_LOGGERS

URL_REDACTION

tai42_kit.logging.redaction.URL_REDACTION

AccessLogQueryMaskingFilter

tai42_kit.logging.logger.AccessLogQueryMaskingFilter
Mask every query-string value in the uvicorn.access request line. The access formatter REBUILDS the line from record.args — a 5-tuple whose third element is the request path + query — and ignores a rewritten record.msg, so the mask is applied by replacing that args element; masking the message alone silently no-ops. Non-matching records pass through untouched. Always returns True — this filter redacts, it never drops.

Members

filter

tai42_kit.logging.logger.AccessLogQueryMaskingFilter.filter
Mask the request path in a matching access record and always keep the record. Parameters

LoggingSettings

tai42_kit.logging.settings.LoggingSettings
Process logging configuration sourced from TAI_-prefixed environment variables. Attributes

Members

validate_log_level

tai42_kit.logging.settings.LoggingSettings.validate_log_level
Normalise log_level to upper case, raising when it is not a known level name. Parameters

is_enabled_for

tai42_kit.logging.settings.LoggingSettings.is_enabled_for
Whether the configured level would emit a record logged at level_name. Parameters

RecordScope

tai42_kit.logging.redaction.RecordScope

install_record_redaction

tai42_kit.logging.redaction.install_record_redaction
Chain one redacting wrapper over logging.getLogRecordFactory(). "tai" scrubs the tai logger family (tai, mcp, fastmcp and names starting tai42_, tai42., tai., mcp., fastmcp.), so an embedding host’s own records pass untouched; "process" scrubs every record. The scope only widens: a later "tai" install never narrows "process". Idempotent: the wrapper is tagged and a repeat install chains nothing. Parameters

logging_settings

tai42_kit.logging.settings.logging_settings
Return the cached LoggingSettings instance.

redact_url_userinfo

tai42_kit.logging.redaction.redact_url_userinfo
scheme://user:pass@host/… -> scheme://***@host/…. The authority ends at the first /, ? or #; the userinfo runs to its last @, so an @ inside a password cannot leak. A string with no :// or no @ in its authority is returned unchanged. Parameters

redact_urls_in_text

tai42_kit.logging.redaction.redact_urls_in_text
Mask every URL in free text: its userinfo and every query-string value become ***. Non-URL text is left untouched. Parameters

register_record_redactor

tai42_kit.logging.redaction.register_record_redactor
Register (or replace, by name) a redactor the record factory applies to in-scope records. Registration alone installs nothing; install_record_redaction chains the factory. Raises ValueError when markers is empty or holds anything but a non-empty string. Parameters

register_transport_redaction

tai42_kit.logging.redaction.register_transport_redaction
Register (or replace, by name) a redactor for the TRANSPORT_LOGGERS records. Installs, once, one filter on each transport logger that applies every registered transport redactor. Raises ValueError when markers is empty or holds anything but a non-empty string. Parameters

setup_logging

tai42_kit.logging.logger.setup_logging
Configure the ROOT logger for an application. Call this from application startup only — never on library import, since it reconfigures the process-global root logger. force=True replaces the existing root handlers, so a repeat call (e.g. after a settings reload) applies the new level instead of being silently ignored. The uvicorn.access logger’s request line carries the full request URL — including query-string capability codes and opaque params — so it is fitted with a masking filter that redacts every query VALUE before the line is formatted. The httpx logger’s own request-line log carries the full outbound URL, credentials included, so it is fitted with a filter that strips the path and query, leaving only the origin. Both attaches are idempotent: a repeat call never stacks a second filter. Logging’s child-side fork hook (install_logging_fork_safety) is registered here, once per process, so a child forked while another thread writes a log line gets its own streams. Parameters