/
log.h
63 lines (52 loc) · 965 Bytes
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright (C) 2015 Kaspar Schleiser
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @addtogroup core_util
* @{
*
* @file log.h
* @brief System logging header
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef __LOG_H
#define __LOG_H
#ifdef __cplusplus
extern "C" {
#endif
enum {
LOG_NONE,
LOG_ERROR,
LOG_WARNING,
LOG_INFO,
LOG_DEBUG,
LOG_ALL
};
#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_ALL
#endif
/**
* @brief Log message if level <= LOG_LEVEL
*
* ... doc to come ...
*
* @{
*/
#define log(level, ...) if (level <= LOG_LEVEL) _log(level, __VA_ARGS__)
/** @} */
#ifdef HAVE_LOG_MODULE
#include "log_module.h"
#else
#include <stdio.h>
#define _log(level, ...) printf(__VA_ARGS__)
#endif
#ifdef __cplusplus
}
#endif
#endif /* __LOG_H */
/** @} */