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#include <stdio.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
43enum {
45 LOG_ERROR,
50 LOG_INFO,
53 LOG_DEBUG,
55 LOG_ALL
56};
57
58#ifndef LOG_LEVEL
62#define LOG_LEVEL LOG_INFO
63#endif
64
68#ifdef __clang__ /* following pragmas required for clang 3.8.0 */
69#define LOG(level, ...) do { \
70 _Pragma("clang diagnostic push") \
71 _Pragma("clang diagnostic ignored \"-Wtautological-compare\"") \
72 if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U) \
73 _Pragma("clang diagnostic pop")
74#else
75#define LOG(level, ...) do { \
76 if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U)
77#endif /* __clang__ */
78
83#define LOG_RIOT_ERROR(...) LOG(LOG_ERROR, __VA_ARGS__)
84#define LOG_RIOT_WARNING(...) LOG(LOG_WARNING, __VA_ARGS__)
85#define LOG_RIOT_INFO(...) LOG(LOG_INFO, __VA_ARGS__)
86#define LOG_RIOT_DEBUG(...) LOG(LOG_DEBUG, __VA_ARGS__)
92#define log_write(level, ...) printf(__VA_ARGS__)
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* OPENWSN_LOG_H */
@ LOG_ERROR
Error log level, will print only critical, non-recoverable errors like hardware initialization failur...
Definition openwsn_log.h:45
@ LOG_INFO
Informational log level, will print purely informational messages like successful system bootup,...
Definition openwsn_log.h:50
@ LOG_NONE
Lowest log level, will output nothing.
Definition openwsn_log.h:44
@ LOG_ALL
print everything
Definition openwsn_log.h:55
@ LOG_WARNING
Warning log level, will print warning messages for temporary errors.
Definition openwsn_log.h:48
@ LOG_DEBUG
Debug log level, printing developer stuff considered too verbose for production use.
Definition openwsn_log.h:53
stdio wrapper to extend the C libs stdio