Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::log Namespace Reference

Logging. More...

Detailed Description

Logging.

Classes

class  Logger
 Logger class with compile-time level filtering. More...
 
struct  NullOutput
 
struct  NullTimestamp
 
struct  SdLogConfig
 
class  SdLogOutput
 
class  TaggedLine
 One #TAG key=value ... line in a fixed buffer. More...
 
class  TaggedValues
 Named values written under one tag, on change, at a capped rate. More...
 
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)
 

Variables

constexpr const char * LOGO_ART
 
constexpr const char * LOGO_BRAND = "Sound Byte " SBL_BANNER_BRAND " "
 
template<typename T >
constexpr bool is_sink_v = detail::is_sink<T>::value
 
template<typename T >
constexpr bool is_timestamp_v = detail::is_timestamp<T>::value
 
constexpr uint8_t TAGGED_MAX_DECIMALS = 6
 
constexpr float TAGGED_MAX_MAGNITUDE = 4.0e9f
 

Enumeration Type Documentation

◆ Level

Log severity levels.

Definition at line 27 of file logger.hpp.

Function Documentation

◆ 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 99 of file banner.hpp.

◆ 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().

◆ 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::system::profiling::format_tagged_histogram(), sbl::log::Logger< Output, TimestampProvider, MinLevel >::log(), sbl::log::Logger< Output, TimestampProvider, MinLevel >::log_simple(), sbl::system::fault::on_hard_fault(), and sbl::system::fault::panic().

◆ level_char()

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

◆ 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 55 of file logger.hpp.

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

Variable Documentation

◆ LOGO_ART

constexpr const char* sbl::log::LOGO_ART
constexpr
Initial value:
=
" .d8888b. 888888b. 888\r\n"
"d88P Y88b888 \"88b 888\r\n"
"Y88b. 888 .88P 888\r\n"
" \"Y888b. 8888888K. 888\r\n"
" \"Y88b.888 \"Y88b888\r\n"
" \"888888 888888\r\n"
"Y88b d88P888 d88P888\r\n"
" \"Y8888P\" 8888888P\" 88888888\r\n"
"----------------------------\r\n"

Definition at line 27 of file logo.hpp.

◆ LOGO_BRAND

constexpr const char* sbl::log::LOGO_BRAND = "Sound Byte " SBL_BANNER_BRAND " "
constexpr

Definition at line 38 of file logo.hpp.

◆ is_sink_v

◆ is_timestamp_v

template<typename T >
constexpr bool sbl::log::is_timestamp_v = detail::is_timestamp<T>::value
inlineconstexpr

True for a type that meets the timestamp contract.

Definition at line 59 of file sink.hpp.

◆ TAGGED_MAX_DECIMALS

constexpr uint8_t sbl::log::TAGGED_MAX_DECIMALS = 6
inlineconstexpr

Decimal places TaggedLine writes a float with at most.

Definition at line 48 of file tagged.hpp.

Referenced by sbl::log::TaggedLine< SIZE >::field().

◆ TAGGED_MAX_MAGNITUDE

constexpr float sbl::log::TAGGED_MAX_MAGNITUDE = 4.0e9f
inlineconstexpr

Largest magnitude format() writes a float at (its integer part is a uint32_t).

Definition at line 51 of file tagged.hpp.

Referenced by sbl::log::TaggedLine< SIZE >::field().