Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
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
33
#ifndef LOG_H
34
#define LOG_H
35
36
#ifdef __cplusplus
37
extern
"C"
{
38
#endif
39
52
enum
{
53
LOG_NONE
,
54
LOG_ERROR
,
57
LOG_WARNING
,
59
LOG_INFO
,
62
LOG_DEBUG
,
64
LOG_ALL
65
};
66
67
#ifndef LOG_LEVEL
71
#define LOG_LEVEL LOG_INFO
72
#endif
73
77
#ifdef __clang__
/* following pragmas required for clang 3.8.0 */
78
#define LOG(level, ...) do { \
79
_Pragma("clang diagnostic push") \
80
_Pragma("clang diagnostic ignored \"-Wtautological-compare\"") \
81
if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U) \
82
_Pragma("clang diagnostic pop")
83
#else
84
#define LOG(level, ...) do { \
85
if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U)
86
#endif
/* __clang__ */
87
92
#define LOG_ERROR(...) LOG(LOG_ERROR, __VA_ARGS__)
93
#define LOG_WARNING(...) LOG(LOG_WARNING, __VA_ARGS__)
94
#define LOG_INFO(...) LOG(LOG_INFO, __VA_ARGS__)
95
#define LOG_DEBUG(...) LOG(LOG_DEBUG, __VA_ARGS__)
98
#ifdef MODULE_LOG
99
#include "log_module.h"
100
#else
101
#include <
stdio.h
>
102
106
#define log_write(level, ...) printf(__VA_ARGS__)
107
#endif
108
109
#ifdef __cplusplus
110
}
111
#endif
112
113
#endif
/* LOG_H */
LOG_INFO
#define LOG_INFO(...)
for the curious
Definition
log.h:94
LOG_DEBUG
#define LOG_DEBUG(...)
teach some ignorance
Definition
log.h:95
LOG_NONE
@ LOG_NONE
Lowest log level, will output nothing.
Definition
log.h:53
LOG_ALL
@ LOG_ALL
print everything
Definition
log.h:64
LOG_ERROR
#define LOG_ERROR(...)
log an error
Definition
log.h:92
LOG_WARNING
#define LOG_WARNING(...)
log a warning
Definition
log.h:93
stdio.h
stdio wrapper to extend the C libs stdio
Generated on Sat Nov 23 2024 01:58:06 by
1.9.8