Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_CLogger.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Dec 9, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7
8#pragma once
9
23#include <drivers/cs_Serial.h> // For SERIAL_VERBOSITY.
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#include <stdbool.h>
30#include <stdint.h>
31
32#if !defined HOST_TARGET && (CS_SERIAL_NRF_LOG_ENABLED == 2)
33// Use NRF Logger instead.
34#define CLOGvv NRF_LOG_DEBUG
35#define CLOGv NRF_LOG_DEBUG
36#define CLOGd NRF_LOG_DEBUG
37#define CLOGi NRF_LOG_INFO
38#define CLOGw NRF_LOG_WARNING
39#define CLOGe NRF_LOG_ERROR
40#define CLOGf NRF_LOG_ERROR
41#define _clog(level, addNewLine, fmt, ...) NRF_LOG_DEBUG(fmt, ##__VA_ARGS__)
42#else
43#define _clog(level, addNewLine, fmt, ...) \
44 if (level <= SERIAL_VERBOSITY) { \
45 cs_clog(addNewLine, fmt, ##__VA_ARGS__); \
46 }
47
48#define CLOGvv(fmt, ...) _clog(SERIAL_VERY_VERBOSE, true, fmt, ##__VA_ARGS__)
49#define CLOGv(fmt, ...) _clog(SERIAL_VERBOSE, true, fmt, ##__VA_ARGS__)
50#define CLOGd(fmt, ...) _clog(SERIAL_DEBUG, true, fmt, ##__VA_ARGS__)
51#define CLOGi(fmt, ...) _clog(SERIAL_INFO, true, fmt, ##__VA_ARGS__)
52#define CLOGw(fmt, ...) _clog(SERIAL_WARN, true, fmt, ##__VA_ARGS__)
53#define CLOGe(fmt, ...) _clog(SERIAL_ERROR, true, fmt, ##__VA_ARGS__)
54#define CLOGf(fmt, ...) _clog(SERIAL_FATAL, true, fmt, ##__VA_ARGS__)
55
56void cs_clog(bool addNewLine, const char* fmt, ...);
57#endif
58
59#ifdef __cplusplus
60}
61#endif
62
63#if SERIAL_VERBOSITY < SERIAL_VERY_VERBOSE
64#undef CLOGvv
65#define CLOGvv(fmt, ...)
66#endif
67
68#if SERIAL_VERBOSITY < SERIAL_VERBOSE
69#undef CLOGv
70#define CLOGv(fmt, ...)
71#endif
72
73#if SERIAL_VERBOSITY < SERIAL_DEBUG
74#undef CLOGd
75#define CLOGd(fmt, ...)
76#endif
77
78#if SERIAL_VERBOSITY < SERIAL_INFO
79#undef CLOGi
80#define CLOGi(fmt, ...)
81#endif
82
83#if SERIAL_VERBOSITY < SERIAL_WARN
84#undef CLOGw
85#define CLOGw(fmt, ...)
86#endif
87
88#if SERIAL_VERBOSITY < SERIAL_ERROR
89#undef CLOGe
90#define CLOGe(fmt, ...)
91#endif
92
93#if SERIAL_VERBOSITY < SERIAL_FATAL
94#undef CLOGf
95#define CLOGf(fmt, ...)
96#endif
void cs_clog(bool addNewLine, const char *fmt,...)