File: dvb-log.h

package info (click to toggle)
v4l-utils 1.32.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,276 kB
  • sloc: ansic: 85,528; cpp: 69,473; perl: 11,915; sh: 1,333; python: 883; php: 119; makefile: 39
file content (110 lines) | stat: -rw-r--r-- 3,465 bytes parent folder | download | duplicates (5)
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
105
106
107
108
109
110
/*
 * 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 Lesser General Public License as published by
 * the Free Software Foundation version 2.1 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser 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
 * @ingroup ancillary
 * @brief Provides interfaces to handle libdvbv5 log messages.
 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
 * @author Mauro Carvalho Chehab
 * @author Andre Roth
 *
 * @par Bug Report
 * Please submit bug reports 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
 * @ingroup ancillary
 */

typedef void (*dvb_logfunc)(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));

/**
 * @typedef void (*dvb_logfunc)(void *logpriv, int level, const char *fmt, ...)
 * @brief typedef used by dvb_fe_open2 for the log function with private context
 * @ingroup ancillary
 */

typedef void (*dvb_logfunc_priv)(void *logpriv, int level, const char *fmt, ...);

/*
 * Macros used internally inside libdvbv5 frontend part, to output logs
 */

#ifndef _DOXYGEN

struct dvb_v5_fe_parms;
/**
 * @brief retrieve the logging function with private data from the private fe params.
 */
dvb_logfunc_priv dvb_get_log_priv(struct dvb_v5_fe_parms *, void **);

#ifndef __DVB_FE_PRIV_H

#define dvb_loglevel(level, fmt, arg...) do {\
    void *priv;\
    dvb_logfunc_priv f = dvb_get_log_priv(parms, &priv);\
    if (f) {\
        f(priv, level, fmt, ##arg);\
    } else {\
        parms->logfunc(level, fmt, ##arg); \
    }\
} while (0)

#else

#define dvb_loglevel(level, fmt, arg...) do {\
    if (parms->logfunc_priv) {\
        parms->logfunc_priv(parms->logpriv, level, fmt, ##arg);\
    } else {\
        parms->p.logfunc(level, fmt, ##arg); \
    }\
} while (0)

#endif

#define dvb_log(fmt, arg...) dvb_loglevel(LOG_INFO, fmt, ##arg)
#define dvb_logerr(fmt, arg...) dvb_loglevel(LOG_ERR, fmt, ##arg)
#define dvb_logdbg(fmt, arg...) dvb_loglevel(LOG_DEBUG, fmt, ##arg)
#define dvb_logwarn(fmt, arg...) dvb_loglevel(LOG_WARNING, fmt, ##arg)
#define dvb_loginfo(fmt, arg...) dvb_loglevel(LOG_NOTICE, fmt, ##arg)

#define dvb_perror(msg) dvb_logerr("%s: %s", msg, strerror(errno))

#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.
 * @ingroup ancillary
 *
 * @param level		level of the message, as defined at syslog.h
 * @param fmt		format string (same as format string on sprintf)
 */
void dvb_default_log(int level, const char *fmt, ...) __attribute__ (( format( printf, 2, 3 )));

#endif