senxor.log
senxor.log¶
Logging utilities for Senxor devices.
get_logger(logger_name='senxor', *args, **kwargs)
¶
Get a structured logger instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The name of the logger, by default |
'senxor'
|
|
Any
|
Positional arguments to pass to |
()
|
|
Any
|
Keyword arguments to pass to |
{}
|
Returns:
| Type | Description |
|---|---|
SenxorLogger
|
A structured logger instance. |
Examples:
>>> from senxor.log import get_logger
>>> logger = get_logger(device_id="1")
>>> logger.warning("This is a warning message.")
[warning ] This is a warning message. device_id=1
setup_standard_logger()
¶
Setup a standard logger.
This logger redirects all messages to the built-in logging module.
It is the default logger for senxor.
This logger is used by default when senxor is used as a library, which
means that senxor should not have any side effects on the logging system.
Instead, use setup_console_logger or setup_file_logger to setup a
logger for your application.
setup_console_logger(log_level='INFO', logger_name='senxor', *, add_logger_name=False)
¶
Setup a console logger.
This logger is used to log messages to the console, can output colored and formatted messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int | str | None
|
The log level to use, by default |
'INFO'
|
|
str
|
The name of the logger, by default |
'senxor'
|
|
bool
|
Whether to add the logger name to the console output, by default |
False
|
setup_file_logger(file_path, file_mode='w', log_level='INFO', logger_name='senxor', *, watch_file=False, json_format=False)
¶
Setup a file logger.
This logger is used to log messages to a file, can output formatted messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path | str
|
The path to the log file. |
required |
|
str
|
The mode to use for the log file, by default |
'w'
|
|
int | str
|
The log level to use, by default |
'INFO'
|
|
str
|
The name of the logger, by default |
'senxor'
|
|
bool
|
Whether to use the |
False
|
|
bool
|
Whether to use the |
False
|