Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions
sbl::log Namespace Reference

Lightweight logging system. More...

Namespaces

namespace  detail
 

Classes

class  Logger
 Logger class with compile-time level filtering. More...
 
struct  NullOutput
 Null output sink (discards all output) More...
 
struct  NullTimestamp
 Default timestamp provider (returns 0) More...
 
struct  SdLogConfig
 
class  SdLogOutput
 
struct  TeeOutput
 

Enumerations

enum class  Level : uint8_t {
  Off = 0 , Error = 1 , Warn = 2 , Info = 3 ,
  Debug = 4 , Trace = 5
}
 Log severity levels. More...
 

Functions

int format_banner (char *buf, size_t size, const char *app_name, uint32_t sample_rate, uint16_t block_size)
 Format a boot banner into a buffer.
 
int vformat (char *buf, size_t size, const char *fmt, va_list args)
 Format a string into a buffer (vsnprintf-style)
 
int format (char *buf, size_t size, const char *fmt,...)
 Format a string into a buffer (snprintf-style)
 
constexpr char level_char (Level level)
 Convert level to single character.
 
constexpr const char * basename (const char *path)
 Extract filename from path (compile-time safe)
 

Detailed Description

Lightweight logging system.

Zero-overhead when disabled. Compile-time level filtering via macros. Configure output sink, timestamp provider, and log level before including <sbl/log/macros.hpp>.

Enumeration Type Documentation

◆ Level

enum class sbl::log::Level : uint8_t
strong

Log severity levels.

Enumerator
Off 
Error 
Warn 
Info 
Debug 
Trace 

Definition at line 26 of file logger.hpp.

Function Documentation

◆ basename()

constexpr const char * sbl::log::basename ( const char *  path)
constexpr

Extract filename from path (compile-time safe)

Returns pointer to last path component (e.g., "main.cpp" from "/foo/bar/main.cpp")

Definition at line 70 of file logger.hpp.

Referenced by sbl::log::Logger< Output, TimestampProvider, MinLevel >::log().

Here is the caller graph for this function:

◆ format()

int sbl::log::format ( char *  buf,
size_t  size,
const char *  fmt,
  ... 
)
inline

Format a string into a buffer (snprintf-style)

Parameters
bufOutput buffer
sizeBuffer size
fmtFormat string
...Arguments
Returns
Number of characters that would have been written (excluding null)

Definition at line 265 of file format.hpp.

References vformat().

Referenced by sbl::profiling::format_report(), sbl::profiling::format_tagged_histogram(), sbl::profiling::format_tagged_report(), sbl::log::Logger< Output, TimestampProvider, MinLevel >::log(), sbl::log::Logger< Output, TimestampProvider, MinLevel >::log_simple(), sbl::fault::on_hard_fault(), and sbl::fault::panic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_banner()

int sbl::log::format_banner ( char *  buf,
size_t  size,
const char *  app_name,
uint32_t  sample_rate,
uint16_t  block_size 
)
inline

Format a boot banner into a buffer.

Parameters
bufOutput buffer
sizeBuffer size (recommend >= 384)
app_nameApplication name (e.g., "hello-instrument")
sample_rateAudio sample rate in Hz (e.g., 48000)
block_sizeAudio block size in frames (e.g., 48)
Returns
Number of characters written (excluding null terminator)

Definition at line 94 of file banner.hpp.

References sbl::log::detail::banner_append(), and sbl::log::detail::banner_append_uint().

Here is the call graph for this function:

◆ level_char()

constexpr char sbl::log::level_char ( Level  level)
constexpr

Convert level to single character.

Definition at line 38 of file logger.hpp.

References Debug, Error, Info, Trace, and Warn.

Referenced by sbl::log::Logger< Output, TimestampProvider, MinLevel >::log(), and sbl::log::Logger< Output, TimestampProvider, MinLevel >::log_simple().

Here is the caller graph for this function:

◆ vformat()

int sbl::log::vformat ( char *  buf,
size_t  size,
const char *  fmt,
va_list  args 
)
inline

Format a string into a buffer (vsnprintf-style)

Parameters
bufOutput buffer
sizeBuffer size
fmtFormat string
argsVariadic argument list
Returns
Number of characters that would have been written (excluding null)

Definition at line 35 of file format.hpp.

Referenced by format(), sbl::log::Logger< Output, TimestampProvider, MinLevel >::log(), and sbl::log::Logger< Output, TimestampProvider, MinLevel >::log_simple().

Here is the caller graph for this function: