idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::log Namespace Reference

Classes

class  logger
 Lightweight logger bound to a specific tag. More...
 

Enumerations

enum class  level : uint8_t {
  none = ESP_LOG_NONE ,
  error = ESP_LOG_ERROR ,
  warn = ESP_LOG_WARN ,
  info = ESP_LOG_INFO ,
  debug = ESP_LOG_DEBUG ,
  verbose = ESP_LOG_VERBOSE
}
 Log severity level. More...
 

Functions

void log (level lvl, const char *tag, std::string_view msg)
 Log a pre-formatted message at the specified level.
 
template<typename... Args>
void log (level lvl, const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at the specified level.
 
template<typename... Args>
void error (const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at error level.
 
void error (const char *tag, std::string_view msg)
 Log a pre-formatted message at error level.
 
template<typename... Args>
void warn (const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at warning level.
 
void warn (const char *tag, std::string_view msg)
 Log a pre-formatted message at warning level.
 
template<typename... Args>
void info (const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at info level.
 
void info (const char *tag, std::string_view msg)
 Log a pre-formatted message at info level.
 
template<typename... Args>
void debug (const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at debug level.
 
void debug (const char *tag, std::string_view msg)
 Log a pre-formatted message at debug level.
 
template<typename... Args>
void verbose (const char *tag, std::format_string< Args... > fmt, Args &&... args)
 Log a message at verbose level.
 
void verbose (const char *tag, std::string_view msg)
 Log a pre-formatted message at verbose level.
 
void set_level (const char *tag, level lvl)
 Set the runtime log level for a specific tag.
 
void set_default_level (level lvl)
 Set the default log level for all tags.
 
void buffer_hex (level lvl, const char *tag, const void *buffer, size_t length)
 Log a buffer as hexadecimal bytes.
 
void buffer_char (level lvl, const char *tag, const void *buffer, size_t length)
 Log a buffer as printable characters.
 
void buffer_hex_dump (level lvl, const char *tag, const void *buffer, size_t length)
 Log a buffer as a formatted hex dump.
 

Enumeration Type Documentation

◆ level

enum class idfxx::log::level : uint8_t
strong

Log severity level.

Severity levels matching ESP-IDF's log levels, from most to least severe. Messages are only output when their level is at or above the configured threshold for the associated tag.

Enumerator
none 

No log output.

error 

Critical errors requiring immediate attention.

warn 

Warning conditions that may indicate problems.

info 

Informational messages about normal operation.

debug 

Detailed information for debugging.

verbose 

Highly detailed trace information.

Definition at line 52 of file log.hpp.

Function Documentation

◆ buffer_char()

void idfxx::log::buffer_char ( level  lvl,
const char *  tag,
const void *  buffer,
size_t  length 
)

Log a buffer as printable characters.

Outputs the buffer contents as characters, 16 per line. Non-printable characters are not shown.

Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
bufferPointer to the buffer data.
lengthNumber of bytes to log.

Referenced by idfxx::log::logger::buffer_char().

◆ buffer_hex()

void idfxx::log::buffer_hex ( level  lvl,
const char *  tag,
const void *  buffer,
size_t  length 
)

Log a buffer as hexadecimal bytes.

Outputs the buffer contents as hex values, 16 bytes per line.

Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
bufferPointer to the buffer data.
lengthNumber of bytes to log.

Referenced by idfxx::log::logger::buffer_hex().

◆ buffer_hex_dump()

void idfxx::log::buffer_hex_dump ( level  lvl,
const char *  tag,
const void *  buffer,
size_t  length 
)

Log a buffer as a formatted hex dump.

Outputs a hex dump with memory addresses, hex values, and ASCII representation, similar to the output of the xxd command.

Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
bufferPointer to the buffer data.
lengthNumber of bytes to log.

Referenced by idfxx::log::logger::buffer_hex_dump().

◆ debug() [1/2]

template<typename... Args>
void idfxx::log::debug ( const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at debug level.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 183 of file log.hpp.

References debug, and log().

◆ debug() [2/2]

void idfxx::log::debug ( const char *  tag,
std::string_view  msg 
)
inline

Log a pre-formatted message at debug level.

Parameters
tagThe log tag identifying the source.
msgThe message string to log.

Definition at line 194 of file log.hpp.

References debug, and log().

◆ error() [1/2]

template<typename... Args>
void idfxx::log::error ( const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at error level.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 108 of file log.hpp.

References error, and log().

◆ error() [2/2]

void idfxx::log::error ( const char *  tag,
std::string_view  msg 
)
inline

Log a pre-formatted message at error level.

Parameters
tagThe log tag identifying the source.
msgThe message string to log.

Definition at line 119 of file log.hpp.

References error, and log().

◆ info() [1/2]

template<typename... Args>
void idfxx::log::info ( const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at info level.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 158 of file log.hpp.

References info, and log().

◆ info() [2/2]

void idfxx::log::info ( const char *  tag,
std::string_view  msg 
)
inline

Log a pre-formatted message at info level.

Parameters
tagThe log tag identifying the source.
msgThe message string to log.

Definition at line 169 of file log.hpp.

References info, and log().

◆ log() [1/2]

template<typename... Args>
void idfxx::log::log ( level  lvl,
const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at the specified level.

The message is only formatted if the tag's runtime log level permits output at the specified severity. Format strings are validated at compile time.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 88 of file log.hpp.

References log().

◆ log() [2/2]

void idfxx::log::log ( level  lvl,
const char *  tag,
std::string_view  msg 
)

Log a pre-formatted message at the specified level.

The message is only output if the tag's runtime log level permits output at the specified severity. No format processing is performed on the message.

Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
msgThe message string to log.

References log().

Referenced by debug(), debug(), error(), error(), info(), info(), log(), log(), idfxx::log::logger::log(), idfxx::log::logger::log(), verbose(), verbose(), warn(), and warn().

◆ set_default_level()

void idfxx::log::set_default_level ( level  lvl)

Set the default log level for all tags.

Tags without a specific level configuration will use this default.

Parameters
lvlThe minimum severity level to output.

◆ set_level()

void idfxx::log::set_level ( const char *  tag,
level  lvl 
)

Set the runtime log level for a specific tag.

Messages with a severity below the configured level are suppressed at runtime for the specified tag.

Parameters
tagThe log tag to configure.
lvlThe minimum severity level to output.

◆ verbose() [1/2]

template<typename... Args>
void idfxx::log::verbose ( const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at verbose level.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 208 of file log.hpp.

References log(), and verbose.

◆ verbose() [2/2]

void idfxx::log::verbose ( const char *  tag,
std::string_view  msg 
)
inline

Log a pre-formatted message at verbose level.

Parameters
tagThe log tag identifying the source.
msgThe message string to log.

Definition at line 219 of file log.hpp.

References log(), and verbose.

◆ warn() [1/2]

template<typename... Args>
void idfxx::log::warn ( const char *  tag,
std::format_string< Args... >  fmt,
Args &&...  args 
)

Log a message at warning level.

Template Parameters
ArgsFormat argument types, deduced from the arguments.
Parameters
tagThe log tag identifying the source.
fmtA std::format format string, validated at compile time.
argsArguments to format into the message.

Definition at line 133 of file log.hpp.

References log(), and warn.

◆ warn() [2/2]

void idfxx::log::warn ( const char *  tag,
std::string_view  msg 
)
inline

Log a pre-formatted message at warning level.

Parameters
tagThe log tag identifying the source.
msgThe message string to log.

Definition at line 144 of file log.hpp.

References log(), and warn.