Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Namespaces | Macros | Typedefs | Functions
macros.hpp File Reference

Zero-overhead logging macros with file/line capture. More...

#include <sbl/log/logger.hpp>
Include dependency graph for macros.hpp:

Go to the source code of this file.

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs functionality.
 
namespace  sbl::log
 
namespace  sbl::log::detail
 

Macros

#define SBL_LOG_LEVEL   3
 
#define SBL_LOG_LEVEL_OFF   0
 
#define SBL_LOG_LEVEL_ERROR   1
 
#define SBL_LOG_LEVEL_WARN   2
 
#define SBL_LOG_LEVEL_INFO   3
 
#define SBL_LOG_LEVEL_DEBUG   4
 
#define SBL_LOG_LEVEL_TRACE   5
 
#define SBL_LOG_OUTPUT   sbl::log::NullOutput
 
#define SBL_LOG_TIMESTAMP   sbl::log::NullTimestamp
 
#define SBL_LOG_ERROR(...)    SblLogger_::log(sbl::log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)
 Main logging macros with compile-time level filtering.
 
#define SBL_LOG_WARN(...)    SblLogger_::log(sbl::log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)
 
#define SBL_LOG_INFO(...)    SblLogger_::log(sbl::log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)
 
#define SBL_LOG_DEBUG(...)    SblLogger_::log(sbl::log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)
 
#define SBL_LOG_TRACE(...)    SblLogger_::log(sbl::log::Level::Trace, __FILE__, __LINE__, __VA_ARGS__)
 
#define SBL_LOG_ERROR_IF(cond, ...)    do { if (cond) { SBL_LOG_ERROR(__VA_ARGS__); } } while(0)
 Conditional logging (runtime condition, compile-time level check)
 
#define SBL_LOG_WARN_IF(cond, ...)    do { if (cond) { SBL_LOG_WARN(__VA_ARGS__); } } while(0)
 
#define SBL_LOG_INFO_IF(cond, ...)    do { if (cond) { SBL_LOG_INFO(__VA_ARGS__); } } while(0)
 
#define SBL_LOG_SIMPLE(lvl, ...)   ((void)0)
 Log without file/line (smaller output)
 

Typedefs

using SblLogger_ = sbl::log::Logger< SBL_LOG_OUTPUT, SBL_LOG_TIMESTAMP, sbl::log::detail::level_from_int(SBL_LOG_LEVEL) >
 

Functions

constexpr Level sbl::log::detail::level_from_int (int lvl)
 

Detailed Description

Zero-overhead logging macros with file/line capture.

Usage: // Define your output sink and timestamp provider struct MyOutput { static void write(const char* s) { ... } }; struct MyTime { static uint32_t now() { return millis(); } };

// Configure before including #define SBL_LOG_OUTPUT MyOutput #define SBL_LOG_TIMESTAMP MyTime #define SBL_LOG_LEVEL sbl::log::Level::Debug #include <sbl/log/macros.hpp>

// Use SBL_LOG_INFO("Hello %s", "world"); SBL_LOG_ERROR("Failed with code %d", err);

Log levels (set SBL_LOG_LEVEL): Level::Off - disable all logging Level::Error - errors only Level::Warn - warnings and above Level::Info - info and above (default) Level::Debug - debug and above Level::Trace - everything

Definition in file macros.hpp.

Macro Definition Documentation

◆ SBL_LOG_DEBUG

#define SBL_LOG_DEBUG (   ...)     SblLogger_::log(sbl::log::Level::Debug, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 100 of file macros.hpp.

◆ SBL_LOG_ERROR

#define SBL_LOG_ERROR (   ...)     SblLogger_::log(sbl::log::Level::Error, __FILE__, __LINE__, __VA_ARGS__)

Main logging macros with compile-time level filtering.

These expand to nothing when the level is disabled, achieving zero overhead for disabled log levels.

Definition at line 79 of file macros.hpp.

◆ SBL_LOG_ERROR_IF

#define SBL_LOG_ERROR_IF (   cond,
  ... 
)     do { if (cond) { SBL_LOG_ERROR(__VA_ARGS__); } } while(0)

Conditional logging (runtime condition, compile-time level check)

Definition at line 116 of file macros.hpp.

◆ SBL_LOG_INFO

#define SBL_LOG_INFO (   ...)     SblLogger_::log(sbl::log::Level::Info, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 93 of file macros.hpp.

◆ SBL_LOG_INFO_IF

#define SBL_LOG_INFO_IF (   cond,
  ... 
)     do { if (cond) { SBL_LOG_INFO(__VA_ARGS__); } } while(0)

Definition at line 122 of file macros.hpp.

◆ SBL_LOG_LEVEL

#define SBL_LOG_LEVEL   3

Definition at line 37 of file macros.hpp.

◆ SBL_LOG_LEVEL_DEBUG

#define SBL_LOG_LEVEL_DEBUG   4

Definition at line 45 of file macros.hpp.

◆ SBL_LOG_LEVEL_ERROR

#define SBL_LOG_LEVEL_ERROR   1

Definition at line 42 of file macros.hpp.

◆ SBL_LOG_LEVEL_INFO

#define SBL_LOG_LEVEL_INFO   3

Definition at line 44 of file macros.hpp.

◆ SBL_LOG_LEVEL_OFF

#define SBL_LOG_LEVEL_OFF   0

Definition at line 41 of file macros.hpp.

◆ SBL_LOG_LEVEL_TRACE

#define SBL_LOG_LEVEL_TRACE   5

Definition at line 46 of file macros.hpp.

◆ SBL_LOG_LEVEL_WARN

#define SBL_LOG_LEVEL_WARN   2

Definition at line 43 of file macros.hpp.

◆ SBL_LOG_OUTPUT

#define SBL_LOG_OUTPUT   sbl::log::NullOutput

Definition at line 50 of file macros.hpp.

◆ SBL_LOG_SIMPLE

#define SBL_LOG_SIMPLE (   lvl,
  ... 
)    ((void)0)

Log without file/line (smaller output)

Definition at line 132 of file macros.hpp.

◆ SBL_LOG_TIMESTAMP

#define SBL_LOG_TIMESTAMP   sbl::log::NullTimestamp

Definition at line 55 of file macros.hpp.

◆ SBL_LOG_TRACE

#define SBL_LOG_TRACE (   ...)     SblLogger_::log(sbl::log::Level::Trace, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 107 of file macros.hpp.

◆ SBL_LOG_WARN

#define SBL_LOG_WARN (   ...)     SblLogger_::log(sbl::log::Level::Warn, __FILE__, __LINE__, __VA_ARGS__)

Definition at line 86 of file macros.hpp.

◆ SBL_LOG_WARN_IF

#define SBL_LOG_WARN_IF (   cond,
  ... 
)     do { if (cond) { SBL_LOG_WARN(__VA_ARGS__); } } while(0)

Definition at line 119 of file macros.hpp.

Typedef Documentation

◆ SblLogger_

Definition at line 66 of file macros.hpp.