Configuration & State¶
Immutable state management and environment detection.
LoggerConfigState
¶
LoggerConfigState(mode: str = 'terminal', highlight_syntax: bool = True, verbose: bool = False, deployed: bool = False, dd_trace_enabled: bool = False, color_enabled: bool = True, force_markup: bool = False, log_prefix: Optional[str] = None, show_thread_name: bool = False, level: LogLevel = LogLevel('INFO'))
Immutable configuration state - no mutations allowed.
is_compact_header_mode
¶
Determines if headers should use compact formatting.
should_add_data_markers
¶
Determines if data markers should be added.
should_enable_dd_trace_logging
¶
Determines if Datadog trace logging should be enabled.
should_highlight_data
¶
Determines if data highlighting should be applied.
should_highlight_json_literals
¶
Determines if JSON literals should be highlighted.
should_show_env_prefix
¶
Determines if environment prefix should be shown.
should_suggest_exceptions
¶
Determines if exception suggestions should be provided.
should_use_json_formatter
¶
Determines if JSON formatter should be used.
single_line_mode
¶
Determines if logs should be formatted as single lines.
should_format_message
¶
Determines if message formatting should be applied.
should_markup
¶
Determines if markup/highlighting should be applied.
should_markup_with_override
¶
Determines markup with potential force override.
should_use_color
¶
Determines if color should be used.
LoggerStateManager
¶
Single Source of Truth for: 1. Configuration state 2. ALL state-dependent services 3. State application logic
apply_temporary_state
¶
Apply temporary state and return old state for restoration.
configure
¶
configure(mode: Optional[Literal['terminal', 'json', 'compact']] = None, level: Optional[logLevels] = None, color_enabled: Optional[bool] = None, highlight_syntax: Optional[bool] = None, verbose: Optional[bool] = None, trace_enabled: Optional[bool] = None, deployment_mode: Optional[bool] = None, force_markup: Optional[bool] = None, suppress_autoconfig: Optional[bool] = False, prefix: object = _UNSET, show_thread_name: Optional[bool] = None) -> LoggerConfigState
Configure state and apply ALL side effects. No external callbacks needed - everything happens here.
create_temporary_state
¶
Create temporary state without applying it.
restore_state
¶
Restore previous state from temporary context.
set_global_logger_manager
¶
Called once during cLogger init to set up GlobalLoggerManager. Needs internal_log callback from cLogger since that's UI/logging, not state.
set_prefix
¶
Set or clear the contextual log prefix shown in all output.
EnvironmentDetector
¶
Detects deployment environment and provides environment-based config.
LogLevel
¶
Defines LogLevel, an enumeration for logging levels.
The LogLevel class provides a specialized enumeration type for different logging levels, supporting standard, alias, and mapped values. It also provides convenient methods for resolving string and integer representations of log levels and for mapping custom aliases to specific log levels.
LogOptions
¶
Configuration options for logging behavior and formatting.