alab_management.logger module#
Logger module takes charge of recording information, warnings and errors during executing tasks.
- class DBLogger(task_id)[source]#
Bases:
object
A custom logger that wrote data to database, where we predefined some log pattern.
- filter_device_signal(device_name, signal_name, within)[source]#
Find device signal log within a range of time (1h/1d or else).
- Parameters:
device_name (str) – name of device
signal_name (str) – name of signal to retrieve
within (timedelta) – timedelta (how far back) to retrieve
- Return type:
dict
[str
,Any
]- Returns:
- Dict[str, Any]: Dictionary containing signal data. Dict form is:
- {
“device_name”: device_name, “signal_name”: signal_name, “timestamp”: [list of timestamps], “value”: [list of signal values] }
- filter_log(level, within)[source]#
Find log within a range of time (1h/1d or else) higher than certain level.
- Return type:
Iterable
[dict
[str
,Any
]]
- get_latest_device_signal(device_name, signal_name)[source]#
Get the last device signal log.
- Parameters:
device_name (str) – device_name
signal_name (str) – signal name
- Return type:
dict
[str
,Any
]- Returns:
Optional[Any]: dictionary with result.
dict example:
{ "device_name": device_name, "signal_name": signal_name, "value": signal_value, "timestamp": timestamp }
- log(level, log_data, logging_type=LoggingType.OTHER)[source]#
Basic log function.
- Parameters:
level (
str
|int
|LoggingLevel
) – the level of this log, which can be string, int orLoggingLevel
log_data (
dict
[str
,Any
]) – the data to be loggedlogging_type (
LoggingType
) – the type of logging.
- Return type:
ObjectId