Abstract backend a Logger fans a formatted line out to. More...
#include <Logger.h>
Public Member Functions | |
| virtual bool | init (const LogConfig &config)=0 |
| Opens whatever handle/socket/file this backend needs, using only fields from config (nothing hardcoded). | |
| virtual void | shutdown ()=0 |
| Releases whatever init() acquired. | |
| virtual void | write (LogLevel level, const char *line, size_t len)=0 |
| Writes one already-formatted, newline-terminated line. | |
| virtual const char * | name () const =0 |
| Short identifier for diagnostics (eg. "UDP", "File"). | |
Abstract backend a Logger fans a formatted line out to.
Every method must be safe to call from any thread and must not block indefinitely - Logger already serializes all calls to a given Logger instance under its own mutex, so a backend does not need its own locking for write(), but must still not do something like an unbounded blocking socket send.
|
pure virtual |
Opens whatever handle/socket/file this backend needs, using only fields from config (nothing hardcoded).
Returning false leaves the backend registered but inert - Logger will simply skip it in dispatch() rather than treat it as fatal, so eg. a missing SD card or unattached USB Gecko degrades gracefully instead of taking the rest of logging down with it.
Implemented in LoggerFile, OgcLoggerSysReport, OgcLoggerUdp, OgcLoggerUsbGecko, WutLoggerOSReport, WutLoggerUdp, and WutLoggerUsbSerial.
|
pure virtual |
Short identifier for diagnostics (eg. "UDP", "File").
Implemented in LoggerFile, OgcLoggerSysReport, OgcLoggerUdp, OgcLoggerUsbGecko, WutLoggerOSReport, WutLoggerUdp, and WutLoggerUsbSerial.
|
pure virtual |
Releases whatever init() acquired.
Must be safe to call even if init() was never called or returned false.
Implemented in LoggerFile, OgcLoggerSysReport, OgcLoggerUdp, OgcLoggerUsbGecko, WutLoggerOSReport, WutLoggerUdp, and WutLoggerUsbSerial.
|
pure virtual |
Writes one already-formatted, newline-terminated line.
len does not include the terminating NUL. Must not allocate.
Implemented in LoggerFile, OgcLoggerSysReport, OgcLoggerUdp, OgcLoggerUsbGecko, WutLoggerOSReport, WutLoggerUdp, and WutLoggerUsbSerial.