OSSS.ai.observability.logger¶
OSSS.ai.observability.logger
¶
Structured logger with observability features.
This module provides enhanced logging capabilities with correlation tracking, structured data, and performance metrics integration.
StructuredLogger
¶
Enhanced logger with structured logging and observability features.
Provides convenient methods for structured logging with automatic correlation ID injection and performance tracking.
NOTE: Public methods (debug/info/warning/error/critical/exception) are intentionally compatible with the stdlib logging.Logger signature: logger.debug(msg, args, *kwargs) so legacy calls like logger.debug("msg", {"foo": "bar"}) or logger.debug("msg %s", value) do not crash.
__init__(name, enable_file_logging=True)
¶
Initialize structured logger.
Parameters¶
name : str Logger name enable_file_logging : bool Whether to enable file logging
debug(message, *args, **kwargs)
¶
Log debug message with structured data.
info(message, *args, **kwargs)
¶
Log info message with structured data.
warning(message, *args, **kwargs)
¶
Log warning message with structured data.
error(message, *args, **kwargs)
¶
Log error message with structured data.
critical(message, *args, **kwargs)
¶
Log critical message with structured data.
exception(message, *args, **kwargs)
¶
Log an error message with exception info (mirrors stdlib Logger.exception()).
log_agent_start(agent_name, step_id=None, **metadata)
¶
Log agent execution start.
log_agent_end(agent_name, success, duration_ms, **metadata)
¶
Log agent execution end.
log_pipeline_start(pipeline_id, agents, **metadata)
¶
Log pipeline execution start.
log_pipeline_end(pipeline_id, success, duration_ms, **metadata)
¶
Log pipeline execution end.
log_llm_call(model, tokens_used, duration_ms, **metadata)
¶
Log LLM API call.
log_llm_stream(model, chunk, **metadata)
¶
Log a streaming chunk from an LLM response.
log_error(error, context=None, **metadata)
¶
Log error with full context.
log_performance_metric(metric_name, value, unit='', **metadata)
¶
Log performance metric.
timed_operation(operation_name, **metadata)
¶
Context manager for timed operations.
TimedOperation
¶
Context manager for timed operations with automatic logging.
setup_enhanced_logging(level=logging.INFO, enable_file_logging=True, structured_console=False)
¶
Setup enhanced logging system.
get_logger(name, enable_file_logging=True)
¶
Get enhanced structured logger.