Logger
Loggers are used to log messages from your application.
For a comprehensive guide on the usage, examples, and additional features of the logging classes, please refer to the reference/concepts/logger section of the Koheesio documentation.
Classes:
Name | Description |
---|---|
LoggingFactory |
Logging factory to be used to generate logger instances. |
Masked |
Represents a masked value. |
MaskedString |
Represents a masked string value. |
MaskedInt |
Represents a masked integer value. |
MaskedFloat |
Represents a masked float value. |
MaskedDict |
Represents a masked dictionary value. |
LoggerIDFilter |
Filter which injects run_id information into the log. |
Functions:
Name | Description |
---|---|
warn |
Issue a warning. |
koheesio.logger.LoggerIDFilter #
koheesio.logger.LoggingFactory #
LoggingFactory(
name: Optional[str] = None,
env: Optional[str] = None,
level: Optional[str] = None,
logger_id: Optional[str] = None,
)
Logging factory to be used to generate logger instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
Optional[str]
|
|
None
|
env |
Optional[str]
|
|
None
|
logger_id |
Optional[str]
|
|
None
|
Source code in src/koheesio/logger.py
LOGGER_FORMAT
class-attribute
instance-attribute
#
LOGGER_FORMAT: str = (
"[%(logger_id)s] [%(asctime)s] [%(levelname)s] [%(name)s] {%(module)s.py:%(funcName)s:%(lineno)d} - %(message)s"
)
LOGGER_FORMATTER
class-attribute
instance-attribute
#
LOGGER_FORMATTER: Formatter = Formatter(LOGGER_FORMAT)
LOGGER_LEVEL
class-attribute
instance-attribute
#
LOGGER_LEVEL: str = get("KOHEESIO_LOGGING_LEVEL", "WARNING")
add_handlers
staticmethod
#
Add handlers to existing root logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
handler_class |
|
required | |
handlers_config |
|
required |
Source code in src/koheesio/logger.py
get_logger
staticmethod
#
Provide logger. If inherit_from_koheesio then inherit from LoggingFactory.PIPELINE_LOGGER_NAME.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
|
required |
inherit_from_koheesio |
bool
|
|
False
|
Returns:
Name | Type | Description |
---|---|---|
logger |
Logger
|
|
Source code in src/koheesio/logger.py
koheesio.logger.Masked #
Masked(value: T)
Represents a masked value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
T
|
The value to be masked. |
required |
Attributes:
Name | Type | Description |
---|---|---|
_value |
T
|
The original value. |
Methods:
Name | Description |
---|---|
__repr__ |
Returns a string representation of the masked value. |
__str__ |
Returns a string representation of the masked value. |
__get_validators__ |
Returns a generator of validators for the masked value. |
validate |
Validates the masked value. |
validate
classmethod
#
validate(v: Any, _values)
Validate the input value and return an instance of the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
Any
|
The input value to validate. |
required |
_values |
Any
|
Additional values used for validation. |
required |
Returns:
Name | Type | Description |
---|---|---|
instance |
cls
|
An instance of the class. |