pytweezer.loggers.base module

Generic Logger base class for InfluxDB metric loggers.

A Logger is a small background worker whose only job is to read some data source and push values into InfluxDB. Concrete loggers subclass this and override setup() (open connections) and read() (return the current values); the base run() loop handles the polling cadence, writing, and teardown.

For a source that pushes data rather than being polled (e.g. a ZMQ subscription), override run() directly instead of read().

Loggers are launched exactly like devices — see pytweezer/servers/logger_server.py and the CONFIG["Loggers"] config category. Nothing reaches InfluxDB unless a Logger (or an explicit InfluxWriter call) puts it there.

class pytweezer.loggers.base.Logger(name, conf)[source]

Bases: object

Base class for background InfluxDB loggers.

Subclasses typically override setup() and read(). Config values live in the logger’s CONFIG["Loggers"][name] entry, available as self.conf. self.writer is a ready-to-use InfluxWriter.

close()[source]

Release resources. Override to add teardown, but call super().close().

read()[source]

Return an iterable of (measurement, fields, tags) tuples, or None.

Called every interval seconds by run(). Override this in a polling logger. tags may be None.

run()[source]

Poll read() every interval seconds and write the results.

Blocks until interrupted (Ctrl-C / SIGTERM). Override for push-driven loggers, but call close() on exit.

setup()[source]

Open connections / prepare state. Override as needed (default: no-op).

stop()[source]