|
Home IO Control
ESPHome add-on for IO-Homecontrol devices
|
Keeps frame-log lines back while the hub answers a device, and prints them afterwards. More...
#include <log_frame.h>
Public Types | |
| using | Sink = void (*)(FrameLogLevel level, const char *tag, const char *text) |
| Prints one line. tag is the logging tag the line was written with. | |
Public Member Functions | |
| FrameLogBuffer (Sink sink) | |
| void | hold () |
| Start keeping lines back. Holding again while held changes nothing. | |
| bool | holding () const |
| uint8_t | held () const |
| void | write (FrameLogLevel level, const char *tag, const char *text) |
| Print text now, or keep it until the next flush() while holding. | |
| void | flush () |
| Print the kept lines in the order they were written, then a note if any did not fit. | |
| void | release () |
| Print the kept lines and stop holding. | |
Keeps frame-log lines back while the hub answers a device, and prints them afterwards.
Printing a log line takes milliseconds, and some receivers drop the hub's answer to their challenge when it comes that much later (issue #163). While held, write() stores each line instead of printing it; flush() prints the stored lines in order. Not holding, write() prints at once. A line that does not fit while held is counted, not printed, and flush() reports the count, so nothing is printed inside the window.
Kept outside the IOHOME_FRAME_LOG guard so its behaviour is unit-testable; firmware builds use the one instance behind frame_log_hold() / frame_log_release().
Definition at line 114 of file log_frame.h.
| using esphome::home_io_control::FrameLogBuffer::Sink = void (*)(FrameLogLevel level, const char *tag, const char *text) |
Prints one line. tag is the logging tag the line was written with.
Definition at line 117 of file log_frame.h.
|
inlineexplicit |
Definition at line 119 of file log_frame.h.
|
inline |
Print the kept lines in the order they were written, then a note if any did not fit.
Keeps holding.
Definition at line 150 of file log_frame.h.
|
inlinenodiscard |
Definition at line 126 of file log_frame.h.
|
inline |
Start keeping lines back. Holding again while held changes nothing.
Definition at line 122 of file log_frame.h.
|
inlinenodiscard |
Definition at line 124 of file log_frame.h.
|
inline |
Print the kept lines and stop holding.
Definition at line 163 of file log_frame.h.
|
inline |
Print text now, or keep it until the next flush() while holding.
| level | Level the line is printed at. |
| tag | Must outlive the hold: a string literal, as every logging tag here is. |
| text | The rendered line; copied (and truncated to FRAME_LOG_LINE_SIZE - 1) when held. |
Definition at line 132 of file log_frame.h.