4
* Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms and conditions of the GNU Lesser General Public License,
8
* version 2.1, as published by the Free Software Foundation.
10
* This program is distributed in the hope it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19
* Ludovic Ferrandis <ludovic.ferrandis@intel.com>
23
#ifndef DLEYNA_LOG_H__
24
#define DLEYNA_LOG_H__
29
enum dleyna_log_type_t_ {
30
DLEYNA_LOG_TYPE_SYSLOG = 0,
34
typedef enum dleyna_log_type_t_ dleyna_log_type_t;
36
void dleyna_log_init(const char *program);
38
void dleyna_log_finalize(void);
40
void dleyna_log_update_type_level(dleyna_log_type_t log_type, int log_level);
42
void dleyna_log_trace(int priority, GLogLevelFlags flags,
43
const char *format, ...)
44
__attribute__((format(printf, 3, 4)));
46
/* Generic Logging macro
48
#ifdef DLEYNA_DEBUG_ENABLED
49
#define DLEYNA_LOG_HELPER(priority, flags, fmt, ...) \
51
dleyna_log_trace(priority, flags, "%s : %s() --- " fmt,\
52
__FILE__, __func__, ## __VA_ARGS__); \
55
#define DLEYNA_LOG_HELPER(priority, flags, fmt, ...) \
57
dleyna_log_trace(priority, flags, fmt, ## __VA_ARGS__);\
62
/* Logging macro for error messages
64
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_ERROR
65
#define DLEYNA_LOG_ERROR(...) \
66
DLEYNA_LOG_HELPER(LOG_ERR, G_LOG_LEVEL_ERROR, __VA_ARGS__, 0)
68
#define DLEYNA_LOG_ERROR(...)
72
/* Logging macro for critical messages
74
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_CRITICAL
75
#define DLEYNA_LOG_CRITICAL(...) \
76
DLEYNA_LOG_HELPER(LOG_CRIT, G_LOG_LEVEL_CRITICAL, \
79
#define DLEYNA_LOG_CRITICAL(...)
83
/* Logging macro for warning messages
85
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_WARNING
86
#define DLEYNA_LOG_WARNING(...) \
87
DLEYNA_LOG_HELPER(LOG_WARNING, G_LOG_LEVEL_WARNING, \
90
#define DLEYNA_LOG_WARNING(...)
94
/* Logging macro for messages
96
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_MESSAGE
97
#define DLEYNA_LOG_MESSAGE(...) \
98
DLEYNA_LOG_HELPER(LOG_NOTICE, G_LOG_LEVEL_MESSAGE, \
101
#define DLEYNA_LOG_MESSAGE(...)
105
/* Logging macro for informational messages
107
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_INFO
108
#define DLEYNA_LOG_INFO(...) \
109
DLEYNA_LOG_HELPER(LOG_INFO, G_LOG_LEVEL_INFO, __VA_ARGS__, 0)
111
#define DLEYNA_LOG_INFO(...)
115
/* Logging macro for debug messages
117
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG
118
#define DLEYNA_LOG_DEBUG(...) \
119
DLEYNA_LOG_HELPER(LOG_DEBUG, G_LOG_LEVEL_DEBUG, __VA_ARGS__, 0)
121
#define DLEYNA_LOG_DEBUG(...)
125
/* Logging macro to display an empty line
127
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_DEBUG
128
#define DLEYNA_LOG_DEBUG_NL() \
130
dleyna_log_trace(LOG_DEBUG, G_LOG_LEVEL_DEBUG, " "); \
133
#define DLEYNA_LOG_DEBUG_NL()
136
#endif /* DLEYNA_LOG_H__ */