Log

class Log[source]

Bases: object

Handles logging of events, errors, alarms, and other system info.

event

Handler for generic events.

Type:

EventBase

temp

Handler for temperature events.

Type:

EventBase

cam

Handler for camera overlay text.

Type:

CameraBase

telegram_bot

Handler for Telegram notifications.

Type:

TelegramBotBase

__init__() None[source]

Initializes the Log system with default handlers.

Methods

__init__()

Initializes the Log system with default handlers.

alarm(description[, subject, exception, report])

Logs an alarm and sends a Telegram notification.

clean_text(exception, description)

Formats an exception traceback into a single line string.

end(task[, subject])

Logs the end of a task.

error(description[, subject, exception])

Logs an error message.

info(description[, subject])

Logs an informational message.

start(task[, subject])

Logs the start of a task.

temperature(temperature, humidity)

Logs temperature and humidity data.

info(description: str, subject: str = 'system') None[source]

Logs an informational message.

Parameters:
  • description (str) – The message content.

  • subject (str) – The subject related to the info.

temperature(temperature: float, humidity: float) None[source]

Logs temperature and humidity data.

Parameters:
  • temperature (float) – The temperature value.

  • humidity (float) – The humidity value.

start(task: str, subject: str = 'system') None[source]

Logs the start of a task.

Parameters:
  • task (str) – The task name.

  • subject (str) – The subject involved.

end(task: str, subject: str = 'system') None[source]

Logs the end of a task.

Parameters:
  • task (str) – The task name.

  • subject (str) – The subject involved.

error(description: str, subject: str = 'system', exception: str | None = None) None[source]

Logs an error message.

Parameters:
  • description (str) – The error description.

  • subject (str) – The subject involved.

  • exception (str | None) – Optional exception traceback string.

alarm(description: str, subject: str = 'system', exception: str | None = None, report: bool = False) None[source]

Logs an alarm and sends a Telegram notification.

Parameters:
  • description (str) – The alarm description.

  • subject (str) – The subject involved.

  • exception (str | None) – Optional exception traceback string.

  • report (bool) – If True, skips logging to event log (used for reports).

clean_text(exception: str | None, description: str) str[source]

Formats an exception traceback into a single line string.

Parameters:
  • exception (str | None) – The exception traceback.

  • description (str) – The initial description.

Returns:

The cleaned and formatted string.

Return type:

str