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
log.hpp
Go to the documentation of this file.
1/**
2 * @file log.hpp
3 * @brief An app's logging: the build's default sink and timestamp, then the macros
4 *
5 * Include this in firmware in place of <sbl/common/log/macros.hpp>. Unless
6 * the app defines them first:
7 *
8 * - SBL_LOG_OUTPUT is the USB CDC serial port in a build with USB
9 * (sbl_setup_usb() defines SBL_HAS_USB), and the debug UART otherwise.
10 * - SBL_LOG_TIMESTAMP is milliseconds from the system timer.
11 *
12 * The choice is made here, above the layers it names, so common/log
13 * depends on none of them. Code without hardware (a unit test, a host tool)
14 * includes <sbl/common/log/macros.hpp> itself and gets sinks that write
15 * nothing unless it defines its own.
16 *
17 * @code
18 * #define SBL_LOG_LEVEL SBL_LOG_LEVEL_DEBUG // optional
19 * #include <sbl/log.hpp>
20 *
21 * SBL_LOG_INFO("tune %d", 440);
22 * @endcode
23 */
24
25#ifndef SBL_LOG_HPP_
26#define SBL_LOG_HPP_
27
29#include <sbl/system/timer.hpp>
30
31#if defined(SBL_HAS_USB)
32#include <sbl/usb/cdc.hpp>
33#endif
34
35#ifndef SBL_LOG_OUTPUT
36#if defined(SBL_HAS_USB)
37#define SBL_LOG_OUTPUT sbl::usb::CdcOutput
38#else
39#define SBL_LOG_OUTPUT sbl::uart::LogOutput
40#endif
41#endif
42
43#ifndef SBL_LOG_TIMESTAMP
44#define SBL_LOG_TIMESTAMP sbl::system::timer::MillisTimestamp
45#endif
46
48
49#endif // SBL_LOG_HPP_
USB CDC (Virtual COM Port) interface.
Log sinks over the debug UART.
Zero-overhead logging macros with file/line capture.
The system timer: the count, 64-bit time, busy waits and millis()