Loading...
Searching...
No Matches
openwsn_log.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
22#ifndef OPENWSN_LOG_H
23#define OPENWSN_LOG_H
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
41enum {
43 LOG_ERROR,
48 LOG_INFO,
51 LOG_DEBUG,
53 LOG_ALL
54};
55
56#ifndef LOG_LEVEL
60#define LOG_LEVEL LOG_INFO
61#endif
62
66#ifdef __clang__ /* following pragmas required for clang 3.8.0 */
67#define LOG(level, ...) do { \
68 _Pragma("clang diagnostic push") \
69 _Pragma("clang diagnostic ignored \"-Wtautological-compare\"") \
70 if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U) \
71 _Pragma("clang diagnostic pop")
72#else
73#define LOG(level, ...) do { \
74 if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U)
75#endif /* __clang__ */
76
81#define LOG_RIOT_ERROR(...) LOG(LOG_ERROR, __VA_ARGS__)
82#define LOG_RIOT_WARNING(...) LOG(LOG_WARNING, __VA_ARGS__)
83#define LOG_RIOT_INFO(...) LOG(LOG_INFO, __VA_ARGS__)
84#define LOG_RIOT_DEBUG(...) LOG(LOG_DEBUG, __VA_ARGS__)
90#define log_write(level, ...) printf(__VA_ARGS__)
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* OPENWSN_LOG_H */
@ LOG_ERROR
Error log level, will print only critical, non-recoverable errors like hardware initialization failur...
Definition openwsn_log.h:43
@ LOG_INFO
Informational log level, will print purely informational messages like successful system bootup,...
Definition openwsn_log.h:48
@ LOG_NONE
Lowest log level, will output nothing.
Definition openwsn_log.h:42
@ LOG_ALL
print everything
Definition openwsn_log.h:53
@ LOG_WARNING
Warning log level, will print warning messages for temporary errors.
Definition openwsn_log.h:46
@ LOG_DEBUG
Debug log level, printing developer stuff considered too verbose for production use.
Definition openwsn_log.h:51