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
tagged.hpp File Reference

Tagged output lines: a builder and a throttled value report. More...

Detailed Description

Tagged output lines: a builder and a throttled value report.

Lines have the tagged-output form #TAG key=value ..., terminated with \r\n. They are written to the sink as built, without the logger's level, time and location prefix, so a host tool reads them by their first character.

TaggedLine builds one line in a fixed buffer. A field that does not fit is left out and the line marks itself overflowed; what it writes is always whole fields.

TaggedValues keeps a set of named values and writes them under one tag when one has moved more than a threshold since the last write and a minimum interval has passed. A change inside the interval is written when the interval ends, so the last value always arrives. Every write carries every value, split over as many lines as the buffer needs.

Both write to the log sink, so both belong to the main loop: the audio and control interrupts never log.

Usage:

line.field("f_hz", 220.0f, 2).field("gate", 1u);
line.write<SBL_LOG_OUTPUT>(); // #WATCH f_hz=220.00 gate=1
sbl::log::TaggedValues<2> watch{"WATCH", {"f_hz", "env"}};
watch.set(0, f_hz); // main loop, every pass
watch.set(1, env_level);
watch.poll<SBL_LOG_OUTPUT>(timer::millis());
One #TAG key=value ... line in a fixed buffer.
Definition tagged.hpp:59
TaggedLine & field(const char *key, float value, uint8_t decimals=3)
A float field, rounded to decimals places.
Definition tagged.hpp:82
Named values written under one tag, on change, at a capped rate.
Definition tagged.hpp:182
void set(size_t index, float value)
Definition tagged.hpp:217

Definition in file tagged.hpp.

#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <sbl/common/log/format.hpp>

Go to the source code of this file.

Classes

class  sbl::log::TaggedLine< SIZE >
 One #TAG key=value ... line in a fixed buffer. More...
 
class  sbl::log::TaggedValues< COUNT, LINE >
 Named values written under one tag, on change, at a capped rate. More...
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::log
 Logging.
 

Variables

constexpr uint8_t sbl::log::TAGGED_MAX_DECIMALS = 6
 
constexpr float sbl::log::TAGGED_MAX_MAGNITUDE = 4.0e9f