Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
esphome::home_io_control::FrameLogBuffer Class Reference

Keeps frame-log lines back while the hub answers a device, and prints them afterwards. More...

#include <log_frame.h>

Collaboration diagram for esphome::home_io_control::FrameLogBuffer:

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.

Detailed Description

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.

Member Typedef Documentation

◆ Sink

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.

Constructor & Destructor Documentation

◆ FrameLogBuffer()

esphome::home_io_control::FrameLogBuffer::FrameLogBuffer ( Sink sink)
inlineexplicit

Definition at line 119 of file log_frame.h.

Member Function Documentation

◆ flush()

void esphome::home_io_control::FrameLogBuffer::flush ( )
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.

◆ held()

uint8_t esphome::home_io_control::FrameLogBuffer::held ( ) const
inlinenodiscard
Returns
number of lines currently kept back.

Definition at line 126 of file log_frame.h.

◆ hold()

void esphome::home_io_control::FrameLogBuffer::hold ( )
inline

Start keeping lines back. Holding again while held changes nothing.

Definition at line 122 of file log_frame.h.

◆ holding()

bool esphome::home_io_control::FrameLogBuffer::holding ( ) const
inlinenodiscard
Returns
true while lines are kept back.

Definition at line 124 of file log_frame.h.

◆ release()

void esphome::home_io_control::FrameLogBuffer::release ( )
inline

Print the kept lines and stop holding.

Definition at line 163 of file log_frame.h.

Here is the call graph for this function:

◆ write()

void esphome::home_io_control::FrameLogBuffer::write ( FrameLogLevel level,
const char * tag,
const char * text )
inline

Print text now, or keep it until the next flush() while holding.

Parameters
levelLevel the line is printed at.
tagMust outlive the hold: a string literal, as every logging tag here is.
textThe rendered line; copied (and truncated to FRAME_LOG_LINE_SIZE - 1) when held.

Definition at line 132 of file log_frame.h.


The documentation for this class was generated from the following file: