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

active_history

Handler for subject active-schedule changes.

Type:

EventBase

cam

Handler for camera overlay text.

Type:

CameraBase

telegram_bot

Handler for Telegram notifications.

Type:

TelegramBotBase

__init__() → None[source]

Methods

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.

active_changed(subject: str, value: str) → None[source]

Logs a change to a subject’s active schedule (ON/OFF/weekly hours).

Recorded so past activity plots (see corridor_plot) can reconstruct what the subject’s schedule actually was at any past hour, instead of applying today’s value retroactively to the whole history. Written to active_history.csv rather than events.csv on purpose: events.csv is high volume and gets trimmed (see Collection.check_split_csv), which would eventually drop a subject’s one-and-only schedule change and silently lose its history.

Parameters:
  • subject (str) – The subject whose active schedule changed.

  • value (str) – The new active value (see convert_active/is_active_at).

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, repeat: 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).

  • repeat (bool) – If True, the alarm is resent in telegram until

  • acknowledged. (it is)

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