logging
¤
ClickLogHandler
¤
Bases: StreamHandler
Logging stream handler that routes and styles log messages through click instead of directly routing to stderr.
This has several advantages, namely, differing log levels can be printed differently to provide additional visual amplification of errors and warnings. Furthermore, there are numerous improvements to support within windows.
See: https://click.palletsprojects.com/en/8.1.x/utils/#printing-to-stdout
stream: TextIO stream to pipe filtered and rendered log messages to
no_color: If True, don't colorize/style log messages by level during rendering
NominalLogHandler
¤
NominalLogHandler(
dataset: Dataset,
log_channel: str = "logs",
max_batch_size: int = 50000,
flush_interval: timedelta = timedelta(seconds=1),
default_args: Mapping[str, str] | None = None,
)
Bases: Handler
A custom logging handler that batches log records and sends them to Nominal in a background thread.
to log custom args from a logger.log(...)
statement, you can pass args as a dictionary via extras
Example: logger.info("infotainment logs", extra={"nominal_args": {"country": "america", "count": 1234}}) This would allow users to see the custom log args within the Nominal log panel.
Parameters:
-
dataset
¤Dataset
) –The dataset object with a
write_logs
method. -
log_channel
¤str
, default:'logs'
) –The channel within the dataset to send logs to
-
max_batch_size
¤int
, default:50000
) –The maximum number of records to hold in the queue before flushing.
-
flush_interval
¤timedelta
, default:timedelta(seconds=1)
) –The maximum time to wait before flushing the queue.
-
default_args
¤Mapping[str, str] | None
, default:None
) –Default key-value pairs to use as arg in all log messages
install_click_log_handler
¤
Install and configure a ClickLogHandler as the default root-level logging handler.
Parameters:
-
level
¤int
, default:WARNING
) –Minimum log severity level for log messages to be allowed to be rendered and emitted.
-
no_color
¤bool
, default:False
) –If true, prevents log messages from being stylized by severity level
Returns:
-
ClickLogHandler
–Attached ClickLogHandler
install_nominal_log_handler
¤
install_nominal_log_handler(
dataset: Dataset,
*,
log_channel: str = "logs",
level: int = INFO,
logger: Logger | None = None,
default_args: Mapping[str, str] | None = None
) -> NominalLogHandler
Install and configure a NominalLogHandler on the provided logger instance.
Parameters:
-
dataset
¤Dataset
) –Nominal dataset to send logs to
-
log_channel
¤str
, default:'logs'
) –Nominal channel to send logs to within the provided dataset
-
level
¤int
, default:INFO
) –Minimum log level to send to Nominal
-
logger
¤Logger | None
, default:None
) –Logger instance to attach the log handler to. Attaches to the root logger by default
-
default_args
¤Mapping[str, str] | None
, default:None
) –Key-value arguments to apply to all log messages by default
Returns:
-
NominalLogHandler
–Attached NominalLogHandler