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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright (c) 2011-2014 - Mauro Carvalho Chehab
* Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation version 2
* of the License.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
#ifndef _LOG_H
#define _LOG_H
#include <syslog.h>
/**
* @file dvb-log.h
* @brief Provides interfaces to handle libdvbv5 log messages.
* @copyright GNU General Public License version 2 (GPLv2)
* @author Mauro Carvalho Chehab
* @author Andre Roth
*
* Please submit bug report and patches to linux-media@vger.kernel.org
*/
/**
* @typedef void (*dvb_logfunc)(int level, const char *fmt, ...)
* @brief typedef used by dvb_fe_open2 for the log function
*/
typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
/*
* Macros used internally inside libdvbv5 frontend part, to output logs
*/
#ifndef _DOXYGEN
#ifndef __DVB_FE_PRIV_H
#define dvb_log(fmt, arg...) do {\
parms->logfunc(LOG_INFO, fmt, ##arg); \
} while (0)
#define dvb_logerr(fmt, arg...) do {\
parms->logfunc(LOG_ERR, fmt, ##arg); \
} while (0)
#define dvb_logdbg(fmt, arg...) do {\
parms->logfunc(LOG_DEBUG, fmt, ##arg); \
} while (0)
#define dvb_logwarn(fmt, arg...) do {\
parms->logfunc(LOG_WARNING, fmt, ##arg); \
} while (0)
#define dvb_loginfo(fmt, arg...) do {\
parms->logfunc(LOG_NOTICE, fmt, ##arg); \
} while (0)
#define dvb_perror(msg) do {\
parms->logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
} while (0)
#else
#define dvb_log(fmt, arg...) do {\
parms->p.logfunc(LOG_INFO, fmt, ##arg); \
} while (0)
#define dvb_logerr(fmt, arg...) do {\
parms->p.logfunc(LOG_ERR, fmt, ##arg); \
} while (0)
#define dvb_logdbg(fmt, arg...) do {\
parms->p.logfunc(LOG_DEBUG, fmt, ##arg); \
} while (0)
#define dvb_logwarn(fmt, arg...) do {\
parms->p.logfunc(LOG_WARNING, fmt, ##arg); \
} while (0)
#define dvb_loginfo(fmt, arg...) do {\
parms->p.logfunc(LOG_NOTICE, fmt, ##arg); \
} while (0)
#define dvb_perror(msg) do {\
parms->p.logfunc(LOG_ERR, "%s: %s", msg, strerror(errno)); \
} while (0)
#endif
#endif /* _DOXYGEN */
/**
* @brief This is the prototype of the internal log function that it is used,
* if the library client doesn't desire to override with something else.
*/
void dvb_default_log(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
#endif
|