-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.h
41 lines (32 loc) · 1.33 KB
/
log.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
#include <string>
#if defined(ARDUINO)
void initlogger();
#endif
namespace logging {
typedef enum { ll_debug, ll_info, ll_warning, ll_error } log_level_t;
log_level_t parse_ll(const std::string & str);
#if defined(ARDUINO)
extern log_level_t log_level_syslog;
void sendsyslog(const logging::log_level_t ll, const char *const component, const std::string context, const char *fmt, ...);
#define DOLOG(ll, component, context, fmt, ...) do { \
if (ll >= logging::log_level_syslog) { \
sendsyslog(ll, component, context, fmt, ##__VA_ARGS__); \
} \
} while(0)
#else
extern log_level_t log_level_file, log_level_screen;
void initlogger();
void setlog(const char *lf, const log_level_t ll_file, const log_level_t ll_screen);
void dolog (const logging::log_level_t ll, const char *const component, const std::string context, const char *fmt, ...);
#define DOLOG(ll, component, context, fmt, ...) do { \
if (ll >= logging::log_level_file || ll >= logging::log_level_screen) \
logging::dolog(ll, component, context, fmt, ##__VA_ARGS__); \
} while(0)
#endif
}
#if defined(ARDUINO)
#include <optional>
#include <string>
extern std::optional<std::string> syslog_host;
void init_logger(const std::string & name);
#endif