pycti.utils.opencti_logger
Classes
Custom JSON formatter for structured logging. |
Functions
|
Create a logger with JSON or standard formatting. |
Module Contents
- class pycti.utils.opencti_logger.CustomJsonFormatter(*args, json_default: Callable | None = None, json_encoder: Callable | None = None, json_serializer: Callable = json.dumps, json_indent: int | str | None = None, json_ensure_ascii: bool = True, **kwargs)[source]
Bases:
pythonjsonlogger.json.JsonFormatterCustom JSON formatter for structured logging.
- Parameters:
args – see [BaseJsonFormatter][pythonjsonlogger.core.BaseJsonFormatter]
json_default – a function for encoding non-standard objects
json_encoder – custom JSON encoder
json_serializer – a [json.dumps](https://docs.python.org/3/library/json.html#json.dumps)-compatible callable that will be used to serialize the log record.
json_indent – indent parameter for the json_serializer
json_ensure_ascii – ensure_ascii parameter for the json_serializer
kwargs – see [BaseJsonFormatter][pythonjsonlogger.core.BaseJsonFormatter]
- pycti.utils.opencti_logger.logger(level, json_logging=True)[source]
Create a logger with JSON or standard formatting.
- Parameters:
level (int) – Logging level (e.g., logging.INFO, logging.DEBUG)
json_logging (bool) – Whether to use JSON formatting for logs
- Returns:
AppLogger class
- Return type:
class