line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* Copyright (C) the libgit2 contributors. All rights reserved. |
3
|
|
|
|
|
|
|
* |
4
|
|
|
|
|
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with |
5
|
|
|
|
|
|
|
* a Linking Exception. For full terms see the included COPYING file. |
6
|
|
|
|
|
|
|
*/ |
7
|
|
|
|
|
|
|
#ifndef INCLUDE_trace_h__ |
8
|
|
|
|
|
|
|
#define INCLUDE_trace_h__ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "common.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#include |
13
|
|
|
|
|
|
|
#include "buffer.h" |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#ifdef GIT_TRACE |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
struct git_trace_data { |
18
|
|
|
|
|
|
|
git_trace_level_t level; |
19
|
|
|
|
|
|
|
git_trace_cb callback; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
extern struct git_trace_data git_trace__data; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
GIT_INLINE(void) git_trace__write_fmt( |
25
|
|
|
|
|
|
|
git_trace_level_t level, |
26
|
|
|
|
|
|
|
const char *fmt, ...) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
git_trace_cb callback = git_trace__data.callback; |
29
|
|
|
|
|
|
|
git_buf message = GIT_BUF_INIT; |
30
|
|
|
|
|
|
|
va_list ap; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
va_start(ap, fmt); |
33
|
|
|
|
|
|
|
git_buf_vprintf(&message, fmt, ap); |
34
|
|
|
|
|
|
|
va_end(ap); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
callback(level, git_buf_cstr(&message)); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
git_buf_dispose(&message); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#define git_trace_level() (git_trace__data.level) |
42
|
|
|
|
|
|
|
#define git_trace(l, ...) { \ |
43
|
|
|
|
|
|
|
if (git_trace__data.level >= l && \ |
44
|
|
|
|
|
|
|
git_trace__data.callback != NULL) { \ |
45
|
|
|
|
|
|
|
git_trace__write_fmt(l, __VA_ARGS__); \ |
46
|
|
|
|
|
|
|
} \ |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#else |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
GIT_INLINE(void) git_trace__null( |
52
|
|
|
|
|
|
|
git_trace_level_t level, |
53
|
|
|
|
|
|
|
const char *fmt, ...) |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
GIT_UNUSED(level); |
56
|
|
|
|
|
|
|
GIT_UNUSED(fmt); |
57
|
0
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#define git_trace_level() ((git_trace_level_t)0) |
60
|
|
|
|
|
|
|
#define git_trace git_trace__null |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#endif |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#endif |