TinyWifiDongle 0.1.0
Header-only USB WiFi dongle for Arduino
Loading...
Searching...
No Matches
twd::LoggerClass Class Reference

Printf-style logger with log levels; use the global TWD_LOGGER object. More...

#include <Logger.h>

Public Types

enum class  LogLevel : uint8_t { Debug , Info , Warning , Error }
 Severity of a log line; lines below the level set with begin() are discarded. More...

Public Member Functions

void begin (Print &out, LogLevel level=LogLevel::Info)
 Lines of level and above are written to out (e.g. Serial); call before starting the dongle.
void end ()
 Stop logging.
void flush ()
 Waits until the output has sent what was written (e.g. before a restart).
void setLevel (LogLevel level)
 Lowest level that is written.
LogLevel level () const
bool enabled (LogLevel level=LogLevel::Info) const
 True if lines of level are written somewhere.
void log (LogLevel level, const char *fmt,...)
 Formats and writes one line of level; does nothing if that level is not enabled.
void debug (const char *fmt,...)
void info (const char *fmt,...)
void warning (const char *fmt,...)
void error (const char *fmt,...)
void vlog (LogLevel level, const char *fmt, va_list ap)
 va_list variant of log().

Detailed Description

Printf-style logger with log levels; use the global TWD_LOGGER object.

Discards everything until the sketch calls begin(), so components can always log without checking whether logging is wanted. Each line is handed to the output with a single write() call, as [dongle] <level letter> <text>.

Definition at line 25 of file Logger.h.

Member Enumeration Documentation

◆ LogLevel

enum class twd::LoggerClass::LogLevel : uint8_t
strong

Severity of a log line; lines below the level set with begin() are discarded.

Enumerator
Debug 
Info 
Warning 
Error 

Definition at line 28 of file Logger.h.

Member Function Documentation

◆ begin()

void twd::LoggerClass::begin ( Print & out,
LogLevel level = LogLevel::Info )
inline

Lines of level and above are written to out (e.g. Serial); call before starting the dongle.

Definition at line 31 of file Logger.h.

◆ debug()

void twd::LoggerClass::debug ( const char * fmt,
... )
inline

Definition at line 57 of file Logger.h.

◆ enabled()

bool twd::LoggerClass::enabled ( LogLevel level = LogLevel::Info) const
inline

True if lines of level are written somewhere.

Definition at line 48 of file Logger.h.

◆ end()

void twd::LoggerClass::end ( )
inline

Stop logging.

Definition at line 36 of file Logger.h.

◆ error()

void twd::LoggerClass::error ( const char * fmt,
... )
inline

Definition at line 75 of file Logger.h.

◆ flush()

void twd::LoggerClass::flush ( )
inline

Waits until the output has sent what was written (e.g. before a restart).

Definition at line 38 of file Logger.h.

◆ info()

void twd::LoggerClass::info ( const char * fmt,
... )
inline

Definition at line 63 of file Logger.h.

◆ level()

LogLevel twd::LoggerClass::level ( ) const
inline

Definition at line 45 of file Logger.h.

◆ log()

void twd::LoggerClass::log ( LogLevel level,
const char * fmt,
... )
inline

Formats and writes one line of level; does nothing if that level is not enabled.

Definition at line 51 of file Logger.h.

◆ setLevel()

void twd::LoggerClass::setLevel ( LogLevel level)
inline

Lowest level that is written.

Definition at line 44 of file Logger.h.

◆ vlog()

void twd::LoggerClass::vlog ( LogLevel level,
const char * fmt,
va_list ap )
inline

va_list variant of log().

Definition at line 83 of file Logger.h.

◆ warning()

void twd::LoggerClass::warning ( const char * fmt,
... )
inline

Definition at line 69 of file Logger.h.


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