tmpllog.c

filter: Statementstmt 43.4% 10 / 23 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 44.0% 11 / 25 SCAR 0
CC
0
Cov
0%
CRAP 0
« callback_stubs.inc ↑ Summary pbuffer.c »
1 /* -*- c -*-
2 * File: log.c
3 * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4 * Created: Thu Sep 1 17:18:16 2005
5 *
6 * $Id$
7 */
8  
9 /* based on FFmpeg av_log API */
10  
11 #include <stdio.h>
12 #include <string.h>
13 #include "tmpllog.h"
14  
15 static int tmpl_log_level = TMPL_LOG_ERROR;
16 TMPLPRO_LOCAL FILE* tmpl_log_stream = NULL;
17  
18 TMPLPRO_LOCAL void
19 0 tmpl_log_default_callback(int level, const char* fmt, va_list vl)
20 {
21 0 vfprintf(stderr, fmt, vl);
22 0 }
23  
24 TMPLPRO_LOCAL void
25 0 tmpl_log_stream_callback(int level, const char* fmt, va_list vl)
26 {
27 0 vfprintf(tmpl_log_stream, fmt, vl);
28 0 fflush(tmpl_log_stream);
29 0 }
30  
31 static void (*tmpl_log_callback)(int, const char*, va_list) = tmpl_log_default_callback;
32  
33 TMPLPRO_LOCAL
34 void
35 63 tmpl_log(int level, const char *fmt, ...)
36 {
37 va_list vl;
38 63 va_start(vl, fmt);
39 63 tmpl_vlog(level, fmt, vl);
40 63 va_end(vl);
41 63 }
42  
43 TMPLPRO_LOCAL
44 void
45 89 tmpl_vlog(int level, const char *fmt, va_list vl)
46 {
47 89 ▶ if(level>tmpl_log_level) return;
Branch: 1 branch
BranchTrueFalseTotal
if(level>tmpl_log_level) return; 89 0 89
48 0 tmpl_log_callback(level, fmt, vl);
49 }
50  
51 TMPLPRO_LOCAL
52 int
53 0 tmpl_log_get_level(void)
54 {
55 0 return tmpl_log_level;
56 }
57  
58 TMPLPRO_LOCAL
59 void
60 448 tmpl_log_set_level(int level)
61 {
62 448 tmpl_log_level = level;
63 448 }
64  
65 TMPLPRO_LOCAL
66 void
67 0 tmpl_log_set_callback(void (*callback)(int, const char*, va_list))
68 {
69 0 tmpl_log_callback = callback;
70 0 }
« callback_stubs.inc ↑ Summary pbuffer.c »