line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* -*- c -*- |
2
|
|
|
|
|
|
|
* File: log.c |
3
|
|
|
|
|
|
|
* Author: Igor Vlasenko |
4
|
|
|
|
|
|
|
* Created: Thu Sep 1 17:18:16 2005 |
5
|
|
|
|
|
|
|
* |
6
|
|
|
|
|
|
|
* $Id$ |
7
|
|
|
|
|
|
|
*/ |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
/* based on FFmpeg av_log API */ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
#include |
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
|
50
|
|
|
|
|
if(level>tmpl_log_level) return; |
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
|
449
|
|
|
|
|
|
tmpl_log_set_level(int level) |
61
|
|
|
|
|
|
|
{ |
62
|
449
|
|
|
|
|
|
tmpl_log_level = level; |
63
|
449
|
|
|
|
|
|
} |
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
|
|
|
|
|
|
} |