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 or LoggingLevel

  • log_data (dict[str, Any]) – the data to be logged

  • logging_type (LoggingType) – the type of logging.

Return type:

ObjectId

log_amount(log_data)[source]#

Log the amount of samples and chemicals (e.g. weight).

log_characterization_result(log_data)[source]#

Log the characterization result (e.g. XRD pattern).

log_device_signal(device_name, signal_name, signal_value)[source]#

Log the device sensor’s signal (e.g. the voltage of batteries, the temperature of furnace).

system_log(level, log_data)[source]#

Log that comes from the workflow system.

class LoggingLevel(value)[source]#

Bases: Enum

Different level log.

CRITICAL = 50#
DEBUG = 10#
ERROR = 40#
FATAL = 50#
INFO = 20#
WARN = 30#
WARNING = 30#
class LoggingType(value)[source]#

Bases: Enum

Different types of log.

CHARACTERIZATION_RESULT = 3#
DEVICE_SIGNAL = 1#
OTHER = 5#
SAMPLE_AMOUNT = 2#
SYSTEM_LOG = 4#