7#ifndef CONFIG_IDFXX_STD_FORMAT
8#error "idfxx_log requires CONFIG_IDFXX_STD_FORMAT to be enabled (menuconfig -> IDFXX -> Enable std::format support)"
88template<
typename...
Args>
108template<
typename...
Args>
120inline void error(
const char* tag, std::string_view
msg) {
133template<
typename...
Args>
145inline void warn(
const char* tag, std::string_view
msg) {
158template<
typename...
Args>
170inline void info(
const char* tag, std::string_view
msg) {
183template<
typename...
Args>
195inline void debug(
const char* tag, std::string_view
msg) {
208template<
typename...
Args>
271template<std::ranges::contiguous_range R>
272 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
274 auto sp = std::span(data);
305template<std::ranges::contiguous_range R>
306 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
308 auto sp = std::span(data);
339template<std::ranges::contiguous_range R>
340 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
342 auto sp = std::span(data);
390 template<
typename...
Args>
410 template<
typename...
Args>
429 template<
typename...
Args>
448 template<
typename...
Args>
467 template<
typename...
Args>
486 template<
typename...
Args>
528 template<std::ranges::contiguous_range R>
529 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
555 template<std::ranges::contiguous_range R>
556 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
581 template<std::ranges::contiguous_range R>
582 requires(
sizeof(std::ranges::range_value_t<R>) == 1)
617 return "unknown(" + std::to_string(
static_cast<unsigned int>(
lvl)) +
")";
628struct formatter<
idfxx::log::level> {
629 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
631 template<
typename FormatContext>
634 return std::copy(s.begin(), s.end(), ctx.out());
652#define IDFXX_LOGE(tag, fmt, ...) \
654 if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { \
655 idfxx::log::error(tag, fmt __VA_OPT__(, ) __VA_ARGS__); \
666#define IDFXX_LOGW(tag, fmt, ...) \
668 if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { \
669 idfxx::log::warn(tag, fmt __VA_OPT__(, ) __VA_ARGS__); \
680#define IDFXX_LOGI(tag, fmt, ...) \
682 if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { \
683 idfxx::log::info(tag, fmt __VA_OPT__(, ) __VA_ARGS__); \
694#define IDFXX_LOGD(tag, fmt, ...) \
696 if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { \
697 idfxx::log::debug(tag, fmt __VA_OPT__(, ) __VA_ARGS__); \
708#define IDFXX_LOGV(tag, fmt, ...) \
710 if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { \
711 idfxx::log::verbose(tag, fmt __VA_OPT__(, ) __VA_ARGS__); \
Lightweight logger bound to a specific tag.
void error(std::string_view msg) const
Log a pre-formatted message at error level.
void buffer_hex(level lvl, const void *buffer, uint16_t length) const
Log a buffer as hexadecimal bytes.
void debug(std::string_view msg) const
Log a pre-formatted message at debug level.
void debug(std::format_string< Args... > fmt, Args &&... args) const
Log a message at debug level.
void info(std::string_view msg) const
Log a pre-formatted message at info level.
void log(level lvl, std::format_string< Args... > fmt, Args &&... args) const
Log a message at the specified level.
void buffer_hex_dump(level lvl, const void *buffer, uint16_t length) const
Log a buffer as a formatted hex dump.
void verbose(std::string_view msg) const
Log a pre-formatted message at verbose level.
void buffer_hex(level lvl, const R &data) const
Log a contiguous range as hexadecimal bytes.
void log(level lvl, std::string_view msg) const
Log a pre-formatted message at the specified level.
void warn(std::string_view msg) const
Log a pre-formatted message at warning level.
void buffer_char(level lvl, const R &data) const
Log a contiguous range as printable characters.
void error(std::format_string< Args... > fmt, Args &&... args) const
Log a message at error level.
void buffer_char(level lvl, const void *buffer, uint16_t length) const
Log a buffer as printable characters.
void warn(std::format_string< Args... > fmt, Args &&... args) const
Log a message at warning level.
void verbose(std::format_string< Args... > fmt, Args &&... args) const
Log a message at verbose level.
constexpr const char * tag() const noexcept
Get the tag associated with this logger.
constexpr logger(const char *tag) noexcept
Construct a logger with the given tag.
void info(std::format_string< Args... > fmt, Args &&... args) const
Log a message at info level.
void buffer_hex_dump(level lvl, const R &data) const
Log a contiguous range as a formatted hex dump.
void set_level(level lvl) const
Set the runtime log level for this logger's tag.
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
void set_level(const char *tag, level lvl)
Set the runtime log level for a specific tag.
void buffer_hex(level lvl, const char *tag, const void *buffer, uint16_t length)
Log a buffer as hexadecimal bytes.
void log(level lvl, const char *tag, std::string_view msg)
Log a pre-formatted message at the specified level.
void set_default_level(level lvl)
Set the default log level for all tags.
void buffer_char(level lvl, const char *tag, const void *buffer, uint16_t length)
Log a buffer 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.
@ warn
Warning conditions that may indicate problems.
@ verbose
Highly detailed trace information.
@ debug
Detailed information for debugging.
@ info
Informational messages about normal operation.
@ error
Critical errors requiring immediate attention.
std::expected< T, std::error_code > result
result type wrapping a value or error code.