forked from nemomobile/mce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mce-log.h
66 lines (59 loc) · 2.64 KB
/
mce-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
64
65
66
/**
* @file mce-log.h
* Headers for the logging functions for Mode Control Entity
* <p>
* Copyright © 2006-2007, 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
* <p>
* @author David Weinehall <[email protected]>
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mce. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MCE_LOG_H_
#define _MCE_LOG_H_
#include <syslog.h> /* LOG_DAEMON, LOG_USER */
#define MCE_LOG_SYSLOG 1 /**< Log to syslog */
#define MCE_LOG_STDERR 0 /**< Log to stderr */
/** Severity of loglevels (subset of syslog priorities) */
typedef enum {
LL_NONE = 0, /**< No logging at all */
LL_CRIT = 2, /**< Critical error */
LL_ERR = 3, /**< Error */
LL_WARN = 4, /**< Warning */
LL_NOTICE = 5, /**< Normal but noteworthy */
LL_INFO = 6, /**< Informational message */
LL_DEBUG = 7, /**< Useful when debugging */
LL_DEFAULT = LL_WARN, /**< Default log level */
} loglevel_t;
#ifdef OSSOLOG_COMPILE
void mce_log_file(loglevel_t loglevel, const char *const file,
const char *const function, const char *const fmt, ...)
__attribute__((format(printf, 4, 5)));
#define mce_log_raw(__loglevel, __fmt, __args...) mce_log_file(__loglevel, NULL, NULL, __fmt , ## __args)
#define mce_log(__loglevel, __fmt, __args...) mce_log_file(__loglevel, __FILE__, __FUNCTION__, __fmt , ## __args)
void mce_log_set_verbosity(const int verbosity);
void mce_log_open(const char *const name, const int facility, const int type);
void mce_log_close(void);
int mce_log_p(const loglevel_t loglevel);
#else
/** Dummy version used when logging is disabled at compile time */
#define mce_log(_loglevel, _fmt, ...) do {} while (0)
/** Dummy version used when logging is disabled at compile time */
#define mce_log_set_verbosity(_verbosity) do {} while (0)
/** Dummy version used when logging is disabled at compile time */
#define mce_log_open(_name, _facility, _type) do {} while (0)
/** Dummy version used when logging is disabled at compile time */
#define mce_log_close() do {} while (0)
/** Dummy version used when logging is disabled at compile time */
#define mce_log_p(_loglevel) 0
#endif /* OSSOLOG_COMPILE */
#endif /* _MCE_LOG_H_ */