libdvbv5  1.20.0
Library to work with Digital TV devices on Linux
dvb-log.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  */
20 
21 #ifndef _LOG_H
22 #define _LOG_H
23 
24 #include <syslog.h>
25 
44 typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
45 
52 typedef void (*dvb_logfunc_priv)(void *logpriv, int level, const char *fmt, ...);
53 
54 /*
55  * Macros used internally inside libdvbv5 frontend part, to output logs
56  */
57 
58 #ifndef _DOXYGEN
59 
60 struct dvb_v5_fe_parms;
64 dvb_logfunc_priv dvb_get_log_priv(struct dvb_v5_fe_parms *, void **);
65 
66 #ifndef __DVB_FE_PRIV_H
67 
68 #define dvb_loglevel(level, fmt, arg...) do {\
69  void *priv;\
70  dvb_logfunc_priv f = dvb_get_log_priv(parms, &priv);\
71  if (f) {\
72  f(priv, level, fmt, ##arg);\
73  } else {\
74  parms->logfunc(level, fmt, ##arg); \
75  }\
76 } while (0)
77 
78 #else
79 
80 #define dvb_loglevel(level, fmt, arg...) do {\
81  if (parms->logfunc_priv) {\
82  parms->logfunc_priv(parms->logpriv, level, fmt, ##arg);\
83  } else {\
84  parms->p.logfunc(level, fmt, ##arg); \
85  }\
86 } while (0)
87 
88 #endif
89 
90 #define dvb_log(fmt, arg...) dvb_loglevel(LOG_INFO, fmt, ##arg)
91 #define dvb_logerr(fmt, arg...) dvb_loglevel(LOG_ERR, fmt, ##arg)
92 #define dvb_logdbg(fmt, arg...) dvb_loglevel(LOG_DEBUG, fmt, ##arg)
93 #define dvb_logwarn(fmt, arg...) dvb_loglevel(LOG_WARNING, fmt, ##arg)
94 #define dvb_loginfo(fmt, arg...) dvb_loglevel(LOG_NOTICE, fmt, ##arg)
95 
96 #define dvb_perror(msg) dvb_logerr("%s: %s", msg, strerror(errno))
97 
98 #endif /* _DOXYGEN */
99 
108 void dvb_default_log(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));
109 
110 #endif
void(* dvb_logfunc)(int level, const char *fmt,...)
typedef used by dvb_fe_open2 for the log function
Definition: dvb-log.h:44
void(* dvb_logfunc_priv)(void *logpriv, int level, const char *fmt,...)
Definition: dvb-log.h:52
void dvb_default_log(int level, const char *fmt,...)
This is the prototype of the internal log function that it is used, if the library client doesn&#39;t des...
Keeps data needed to handle the DVB frontend.
Definition: dvb-fe.h:117