| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
MODULE = XLog PACKAGE = XLog::Formatter |
|
2
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
PerlObjectFormatter* PerlObjectFormatter::new () { |
|
5
|
2
|
|
|
|
|
|
PROTO = Stash::from_name(CLASS).bless(Hash::create()); |
|
6
|
1
|
50
|
|
|
|
|
RETVAL = new PerlObjectFormatter(); |
|
7
|
1
|
50
|
|
|
|
|
} |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
8
|
1
|
50
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MODE: INLINE |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
static const char* DECORATOR_KEY = "_decorator"; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
// let it be only script basename, without file |
|
14
|
|
|
|
|
|
|
static string decorate_default(const char* name) { |
|
15
|
|
|
|
|
|
|
string in(name); |
|
16
|
|
|
|
|
|
|
auto pos = in.find_last_of("/\\"); |
|
17
|
|
|
|
|
|
|
if (pos == string::npos) { |
|
18
|
|
|
|
|
|
|
return in; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
return in.substr(pos + 1); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
static xs::Sv::payload_marker_t spy_$0_marker{}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
static int spy_$0(pTHX_ SV* sv, MAGIC* mg) { |
|
26
|
|
|
|
|
|
|
if (mg->mg_virtual == &spy_$0_marker) { |
|
27
|
|
|
|
|
|
|
Stash stash("XLog::Formatter::Pattern"); |
|
28
|
|
|
|
|
|
|
auto decorator = stash.sub(DECORATOR_KEY); |
|
29
|
|
|
|
|
|
|
string $0; |
|
30
|
|
|
|
|
|
|
if (decorator) { |
|
31
|
|
|
|
|
|
|
auto decorated = decorator.call(sv); |
|
32
|
|
|
|
|
|
|
$0 = SvPV_nolen(decorated); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
else { |
|
35
|
|
|
|
|
|
|
$0 = decorate_default(SvPV_nolen(sv)); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
set_program_name($0); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
return 0; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
MODULE = XLog PACKAGE = XLog::Formatter::Pattern |
|
43
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
BOOT { |
|
46
|
8
|
50
|
|
|
|
|
Stash(__PACKAGE__).inherit("XLog::IFormatter"); |
|
|
|
50
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
8
|
|
|
|
|
|
spy_$0_marker.svt_set = spy_$0; |
|
49
|
|
|
|
|
|
|
|
|
50
|
8
|
50
|
|
|
|
|
auto $0_sv = get_sv("0", 0); |
|
51
|
|
|
|
|
|
|
MAGIC* mg; |
|
52
|
8
|
50
|
|
|
|
|
Newx(mg, 1, MAGIC); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
53
|
8
|
|
|
|
|
|
mg->mg_moremagic = SvMAGIC($0_sv); |
|
54
|
8
|
|
|
|
|
|
SvMAGIC_set($0_sv, mg); |
|
55
|
8
|
|
|
|
|
|
mg->mg_virtual = const_cast(&spy_$0_marker); |
|
56
|
8
|
|
|
|
|
|
mg->mg_type = PERL_MAGIC_ext; |
|
57
|
8
|
|
|
|
|
|
mg->mg_len = 0; |
|
58
|
8
|
|
|
|
|
|
mg->mg_private = 0; |
|
59
|
8
|
|
|
|
|
|
mg->mg_flags = 0; |
|
60
|
8
|
|
|
|
|
|
mg->mg_ptr = NULL; |
|
61
|
8
|
|
|
|
|
|
mg->mg_obj = NULL; |
|
62
|
|
|
|
|
|
|
|
|
63
|
8
|
50
|
|
|
|
|
auto $0 = SvPV_nolen($0_sv); |
|
|
|
50
|
|
|
|
|
|
|
64
|
8
|
50
|
|
|
|
|
set_program_name(decorate_default($0)); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
|
IFormatter* PatternFormatter::new (string_view fmt) |
|
68
|
1
|
50
|
|
|
|
|
|
|
69
|
1
|
50
|
|
|
|
|
void set_program_decorator(Sub callback) { |
|
|
|
50
|
|
|
|
|
|
|
70
|
2
|
50
|
|
|
|
|
Stash stash(__PACKAGE__); |
|
71
|
1
|
50
|
|
|
|
|
stash.store(DECORATOR_KEY, callback); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|