-
Notifications
You must be signed in to change notification settings - Fork 1
/
scd30_logging.h
71 lines (57 loc) · 1.91 KB
/
scd30_logging.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
// Based on https://github.com/csBlueChip/FlipperZero_plugin_howto/blob/main/bc_logging.h (MIT license)
#include <furi.h>
#include "err.h" // appName
//----------------------------------------------------------------------------- ----------------------------------------
// FURI logging has 6 levels (numbered 1 thru 6}
// 1. None
// 2. Errors FURI_LOG_E
// 3. Warnings FURI_LOG_W
// 4. Information FURI_LOG_I
// 5. Debug FURI_LOG_D
// 6. Trace FURI_LOG_T
//
// --> furi/core/log.h
//
// The FlipperZero Settings->System menu allows you to set the logging level at RUN-time
// This lets you limit it at COMPILE-time
// #ifndef LOG_LEVEL
#undef LOG_LEVEL
#define LOG_LEVEL 6
// #endif
#if (LOG_LEVEL < 2)
# undef FURI_LOG_E
# define FURI_LOG_E(tag, fmt, ...)
#endif
#if (LOG_LEVEL < 3)
# undef FURI_LOG_W
# define FURI_LOG_W(tag, fmt, ...)
#endif
#if (LOG_LEVEL < 4)
# undef FURI_LOG_I
# define FURI_LOG_I(tag, fmt, ...)
#endif
#if (LOG_LEVEL < 5)
# undef FURI_LOG_D
# define FURI_LOG_D(tag, fmt, ...)
#endif
#if (LOG_LEVEL < 6)
# undef FURI_LOG_T
# define FURI_LOG_T(tag, fmt, ...)
#endif
//----------------------------------------------------------
// Logging helper macros
//
#define ERROR(fmt, ...) FURI_LOG_E(appName, fmt __VA_OPT__(,) __VA_ARGS__)
#define WARN(fmt, ...) FURI_LOG_W(appName, fmt __VA_OPT__(,) __VA_ARGS__)
#define INFO(fmt, ...) FURI_LOG_I(appName, fmt __VA_OPT__(,) __VA_ARGS__)
#define DEBUG(fmt, ...) FURI_LOG_D(appName, fmt __VA_OPT__(,) __VA_ARGS__)
#define TRACE(fmt, ...) FURI_LOG_T(appName, fmt __VA_OPT__(,) __VA_ARGS__)
#define ENTER TRACE("(+) %s", __func__)
#define LEAVE TRACE("(-) %s", __func__)
#define SCOPED_ENTER ScopedDebug _sd(__func__)
struct ScopedDebug {
const char *func = nullptr;
ScopedDebug(const char *func_): func(func_) { TRACE("(+) %s", func); }
~ScopedDebug() { TRACE("(-) %s", func); }
};