Logger
provide.foundation.logger
¶
TODO: Add module docstring.
Classes¶
FoundationLogger
¶
A structlog-based logger providing a standardized logging interface.
Source code in provide/foundation/logger/core.py
Functions¶
__setattr__
¶
Override setattr to prevent accidental modification of logger state.
Source code in provide/foundation/logger/core.py
bind
¶
Create a new logger with additional context bound to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Key-value pairs to bind to the logger |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A new logger instance with the bound context |
Source code in provide/foundation/logger/core.py
critical
¶
Log critical-level event.
debug
¶
error
¶
exception
¶
Log error-level event with exception traceback.
Source code in provide/foundation/logger/core.py
info
¶
setup
¶
Setup the logger with configuration from Hub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
TelemetryConfig
|
TelemetryConfig to use for setup |
required |
Source code in provide/foundation/logger/core.py
trace
¶
Log trace-level event for detailed debugging.
Source code in provide/foundation/logger/core.py
try_unbind
¶
Create a new logger with specified keys removed from context. Does not raise an error if keys don't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*keys
|
str
|
Context keys to remove |
()
|
Returns:
| Type | Description |
|---|---|
Any
|
A new logger instance without the specified keys |
Source code in provide/foundation/logger/core.py
unbind
¶
Create a new logger with specified keys removed from context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*keys
|
str
|
Context keys to remove |
()
|
Returns:
| Type | Description |
|---|---|
Any
|
A new logger instance without the specified keys |
Source code in provide/foundation/logger/core.py
warning
¶
Log warning-level event.
LoggingConfig
¶
TelemetryConfig
¶
Bases: RuntimeConfig
Main configuration object for the Foundation Telemetry system.
Functions¶
from_env
classmethod
¶
from_env(
prefix: str = "",
delimiter: str = "_",
case_sensitive: bool = False,
) -> TelemetryConfig
Load configuration from environment variables.
This method explicitly provides the from_env() interface to ensure it's available on TelemetryConfig directly.
If OpenObserve is configured and reachable, OTLP settings are automatically configured if not already set.
Source code in provide/foundation/logger/config/telemetry.py
Functions¶
get_logger
¶
Get a logger instance through Hub with circular import protection.
This function provides access to the global logger instance. It is preserved for backward compatibility but should be avoided in new application code in favor of explicit Dependency Injection.
Circular Import Protection
Uses thread-local state to detect recursive initialization and falls back to basic structlog when circular dependencies are detected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Logger name (e.g., name from a module) |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Configured structlog logger instance |
Note
For building testable and maintainable applications, the recommended
approach is to inject a logger instance via a Container. See the
Dependency Injection guide for more information.