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, uint16_t length)
 Log a buffer as hexadecimal bytes.
 
template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void buffer_hex (level lvl, const char *tag, const R &data)
 Log a contiguous range as hexadecimal bytes.
 
void buffer_char (level lvl, const char *tag, const void *buffer, uint16_t length)
 Log a buffer as printable characters.
 
template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void buffer_char (level lvl, const char *tag, const R &data)
 Log a contiguous range as printable characters.
 
void buffer_hex_dump (level lvl, const char *tag, const void *buffer, uint16_t length)
 Log a buffer as a formatted hex dump.
 
template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void buffer_hex_dump (level lvl, const char *tag, const R &data)
 Log a contiguous range as a formatted hex dump.
 

Enumeration Type Documentation

◆ level

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 53 of file log.hpp.

Function Documentation

◆ buffer_char() [1/2]

template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void idfxx::log::buffer_char ( level  lvl,
const char tag,
const R data 
)

Log a contiguous range as printable characters.

Outputs the buffer contents as characters, 16 per line. Non-printable characters are not shown. Only the first 65535 bytes are logged; any remainder is silently truncated.

Template Parameters
RA contiguous range type (e.g., std::vector, std::span, std::array).
Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
dataThe data to log.

Definition at line 307 of file log.hpp.

References buffer_char().

◆ buffer_char() [2/2]

void idfxx::log::buffer_char ( level  lvl,
const char tag,
const void buffer,
uint16_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 buffer_char(), idfxx::log::logger::buffer_char(), and idfxx::log::logger::buffer_char().

◆ buffer_hex() [1/2]

template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void idfxx::log::buffer_hex ( level  lvl,
const char tag,
const R data 
)

Log a contiguous range as hexadecimal bytes.

Outputs the buffer contents as hex values, 16 bytes per line. Only the first 65535 bytes are logged; any remainder is silently truncated.

Template Parameters
RA contiguous range type (e.g., std::vector, std::span, std::array).
Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
dataThe data to log.

Definition at line 273 of file log.hpp.

References buffer_hex().

◆ buffer_hex() [2/2]

void idfxx::log::buffer_hex ( level  lvl,
const char tag,
const void buffer,
uint16_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 buffer_hex(), idfxx::log::logger::buffer_hex(), and idfxx::log::logger::buffer_hex().

◆ buffer_hex_dump() [1/2]

template<std::ranges::contiguous_range R>
requires (sizeof(std::ranges::range_value_t<R>) == 1)
void idfxx::log::buffer_hex_dump ( level  lvl,
const char tag,
const R data 
)

Log a contiguous range 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. Only the first 65535 bytes are logged; any remainder is silently truncated.

Template Parameters
RA contiguous range type (e.g., std::vector, std::span, std::array).
Parameters
lvlThe log severity level.
tagThe log tag identifying the source.
dataThe data to log.

Definition at line 341 of file log.hpp.

References buffer_hex_dump().

◆ buffer_hex_dump() [2/2]

void idfxx::log::buffer_hex_dump ( level  lvl,
const char tag,
const void buffer,
uint16_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 buffer_hex_dump(), idfxx::log::logger::buffer_hex_dump(), and 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 184 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 195 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 109 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 120 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 159 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 170 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 89 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 209 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 220 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 134 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 145 of file log.hpp.

References log(), and warn.