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
37extern "C" {
38#endif
39
52enum {
54 LOG_ERROR,
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 */
#define LOG_INFO(...)
for the curious
Definition log.h:94
#define LOG_DEBUG(...)
teach some ignorance
Definition log.h:95
@ LOG_NONE
Lowest log level, will output nothing.
Definition log.h:53
@ LOG_ALL
print everything
Definition log.h:64
#define LOG_ERROR(...)
log an error
Definition log.h:92
#define LOG_WARNING(...)
log a warning
Definition log.h:93
stdio wrapper to extend the C libs stdio