| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* This file was generated automatically by ExtUtils::ParseXS version 3.34 from the |
|
3
|
|
|
|
|
|
|
* contents of XLog.xs. Do not edit this file, edit XLog.xs instead. |
|
4
|
|
|
|
|
|
|
* |
|
5
|
|
|
|
|
|
|
* ANY CHANGES MADE HERE WILL BE LOST! |
|
6
|
|
|
|
|
|
|
* |
|
7
|
|
|
|
|
|
|
*/ |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#line 1 "XLog.xs" |
|
10
|
|
|
|
|
|
|
#include |
|
11
|
|
|
|
|
|
|
#include |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
using namespace xs; |
|
14
|
|
|
|
|
|
|
using namespace panda; |
|
15
|
|
|
|
|
|
|
using namespace panda::log; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#line 18 "XLog_xsgen.cc" |
|
18
|
|
|
|
|
|
|
#ifndef PERL_UNUSED_VAR |
|
19
|
|
|
|
|
|
|
# define PERL_UNUSED_VAR(var) if (0) var = var |
|
20
|
|
|
|
|
|
|
#endif |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#ifndef dVAR |
|
23
|
|
|
|
|
|
|
# define dVAR dNOOP |
|
24
|
|
|
|
|
|
|
#endif |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
/* This stuff is not part of the API! You have been warned. */ |
|
28
|
|
|
|
|
|
|
#ifndef PERL_VERSION_DECIMAL |
|
29
|
|
|
|
|
|
|
# define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) |
|
30
|
|
|
|
|
|
|
#endif |
|
31
|
|
|
|
|
|
|
#ifndef PERL_DECIMAL_VERSION |
|
32
|
|
|
|
|
|
|
# define PERL_DECIMAL_VERSION \ |
|
33
|
|
|
|
|
|
|
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) |
|
34
|
|
|
|
|
|
|
#endif |
|
35
|
|
|
|
|
|
|
#ifndef PERL_VERSION_GE |
|
36
|
|
|
|
|
|
|
# define PERL_VERSION_GE(r,v,s) \ |
|
37
|
|
|
|
|
|
|
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) |
|
38
|
|
|
|
|
|
|
#endif |
|
39
|
|
|
|
|
|
|
#ifndef PERL_VERSION_LE |
|
40
|
|
|
|
|
|
|
# define PERL_VERSION_LE(r,v,s) \ |
|
41
|
|
|
|
|
|
|
(PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s)) |
|
42
|
|
|
|
|
|
|
#endif |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
/* XS_INTERNAL is the explicit static-linkage variant of the default |
|
45
|
|
|
|
|
|
|
* XS macro. |
|
46
|
|
|
|
|
|
|
* |
|
47
|
|
|
|
|
|
|
* XS_EXTERNAL is the same as XS_INTERNAL except it does not include |
|
48
|
|
|
|
|
|
|
* "STATIC", ie. it exports XSUB symbols. You probably don't want that |
|
49
|
|
|
|
|
|
|
* for anything but the BOOT XSUB. |
|
50
|
|
|
|
|
|
|
* |
|
51
|
|
|
|
|
|
|
* See XSUB.h in core! |
|
52
|
|
|
|
|
|
|
*/ |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
/* TODO: This might be compatible further back than 5.10.0. */ |
|
56
|
|
|
|
|
|
|
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1) |
|
57
|
|
|
|
|
|
|
# undef XS_EXTERNAL |
|
58
|
|
|
|
|
|
|
# undef XS_INTERNAL |
|
59
|
|
|
|
|
|
|
# if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
|
60
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name) |
|
61
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC XSPROTO(name) |
|
62
|
|
|
|
|
|
|
# endif |
|
63
|
|
|
|
|
|
|
# if defined(__SYMBIAN32__) |
|
64
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) EXPORT_C XSPROTO(name) |
|
65
|
|
|
|
|
|
|
# define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name) |
|
66
|
|
|
|
|
|
|
# endif |
|
67
|
|
|
|
|
|
|
# ifndef XS_EXTERNAL |
|
68
|
|
|
|
|
|
|
# if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
|
69
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__) |
|
70
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__) |
|
71
|
|
|
|
|
|
|
# else |
|
72
|
|
|
|
|
|
|
# ifdef __cplusplus |
|
73
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) extern "C" XSPROTO(name) |
|
74
|
|
|
|
|
|
|
# define XS_INTERNAL(name) static XSPROTO(name) |
|
75
|
|
|
|
|
|
|
# else |
|
76
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) XSPROTO(name) |
|
77
|
|
|
|
|
|
|
# define XS_INTERNAL(name) STATIC XSPROTO(name) |
|
78
|
|
|
|
|
|
|
# endif |
|
79
|
|
|
|
|
|
|
# endif |
|
80
|
|
|
|
|
|
|
# endif |
|
81
|
|
|
|
|
|
|
#endif |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
/* perl >= 5.10.0 && perl <= 5.15.1 */ |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
/* The XS_EXTERNAL macro is used for functions that must not be static |
|
87
|
|
|
|
|
|
|
* like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL |
|
88
|
|
|
|
|
|
|
* macro defined, the best we can do is assume XS is the same. |
|
89
|
|
|
|
|
|
|
* Dito for XS_INTERNAL. |
|
90
|
|
|
|
|
|
|
*/ |
|
91
|
|
|
|
|
|
|
#ifndef XS_EXTERNAL |
|
92
|
|
|
|
|
|
|
# define XS_EXTERNAL(name) XS(name) |
|
93
|
|
|
|
|
|
|
#endif |
|
94
|
|
|
|
|
|
|
#ifndef XS_INTERNAL |
|
95
|
|
|
|
|
|
|
# define XS_INTERNAL(name) XS(name) |
|
96
|
|
|
|
|
|
|
#endif |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
/* Now, finally, after all this mess, we want an ExtUtils::ParseXS |
|
99
|
|
|
|
|
|
|
* internal macro that we're free to redefine for varying linkage due |
|
100
|
|
|
|
|
|
|
* to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use |
|
101
|
|
|
|
|
|
|
* XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to! |
|
102
|
|
|
|
|
|
|
*/ |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#undef XS_EUPXS |
|
105
|
|
|
|
|
|
|
#if defined(PERL_EUPXS_ALWAYS_EXPORT) |
|
106
|
|
|
|
|
|
|
# define XS_EUPXS(name) XS_EXTERNAL(name) |
|
107
|
|
|
|
|
|
|
#else |
|
108
|
|
|
|
|
|
|
/* default to internal */ |
|
109
|
|
|
|
|
|
|
# define XS_EUPXS(name) XS_INTERNAL(name) |
|
110
|
|
|
|
|
|
|
#endif |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
|
113
|
|
|
|
|
|
|
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
/* prototype to pass -Wmissing-prototypes */ |
|
116
|
|
|
|
|
|
|
STATIC void |
|
117
|
|
|
|
|
|
|
S_croak_xs_usage(const CV *const cv, const char *const params); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
STATIC void |
|
120
|
|
|
|
|
|
|
S_croak_xs_usage(const CV *const cv, const char *const params) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
|
|
|
|
|
|
const GV *const gv = CvGV(cv); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
PERL_ARGS_ASSERT_CROAK_XS_USAGE; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
if (gv) { |
|
127
|
|
|
|
|
|
|
const char *const gvname = GvNAME(gv); |
|
128
|
|
|
|
|
|
|
const HV *const stash = GvSTASH(gv); |
|
129
|
|
|
|
|
|
|
const char *const hvname = stash ? HvNAME(stash) : NULL; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
if (hvname) |
|
132
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params); |
|
133
|
|
|
|
|
|
|
else |
|
134
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: %s(%s)", gvname, params); |
|
135
|
|
|
|
|
|
|
} else { |
|
136
|
|
|
|
|
|
|
/* Pants. I don't think that it should be possible to get here. */ |
|
137
|
|
|
|
|
|
|
Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#define croak_xs_usage S_croak_xs_usage |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#endif |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
/* NOTE: the prototype of newXSproto() is different in versions of perls, |
|
147
|
|
|
|
|
|
|
* so we define a portable version of newXSproto() |
|
148
|
|
|
|
|
|
|
*/ |
|
149
|
|
|
|
|
|
|
#ifdef newXS_flags |
|
150
|
|
|
|
|
|
|
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0) |
|
151
|
|
|
|
|
|
|
#else |
|
152
|
|
|
|
|
|
|
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv) |
|
153
|
|
|
|
|
|
|
#endif /* !defined(newXS_flags) */ |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
|
156
|
|
|
|
|
|
|
# define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file) |
|
157
|
|
|
|
|
|
|
#else |
|
158
|
|
|
|
|
|
|
# define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b) |
|
159
|
|
|
|
|
|
|
#endif |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#line 162 "XLog_xsgen.cc" |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/XLog.xsi' from 'XLog.xs' */ |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
#include "util.h" |
|
166
|
|
|
|
|
|
|
using namespace xs::xlog; |
|
167
|
|
|
|
|
|
|
namespace { |
|
168
|
|
|
|
|
|
|
static bool no_format_warnings; |
|
169
|
|
|
|
|
|
|
|
|
170
|
2
|
|
|
|
|
|
struct PerlObjectFormatter : IFormatter, Backref { |
|
171
|
1
|
|
|
|
|
|
string format (std::string& msg, const Info& i) const override { |
|
172
|
1
|
50
|
|
|
|
|
if (!is_perl_thread()) throw std::logic_error("can't call pure-perl formatting callback: log() called from perl-foreign thread"); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
173
|
2
|
50
|
|
|
|
|
Object o = xs::out(this); |
|
|
|
50
|
|
|
|
|
|
|
174
|
2
|
50
|
|
|
|
|
auto ret = o.call("format", xs::out(msg), xs::out(i.level), xs::out(i.module->name()), xs::out(i.file), xs::out(i.line), xs::out(i.func)); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
175
|
2
|
50
|
|
|
|
|
return xs::in(ret); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
4
|
50
|
|
|
|
|
~PerlObjectFormatter () { Backref::dtor(); } |
|
179
|
|
|
|
|
|
|
}; |
|
180
|
|
|
|
|
|
|
|
|
181
|
50
|
|
|
|
|
|
struct PerlObjectLogger : ILogger, Backref { |
|
182
|
123
|
|
|
|
|
|
void log_format (std::string& msg, const Info& i, const IFormatter& fmt) override { |
|
183
|
123
|
50
|
|
|
|
|
if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread"); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
184
|
246
|
50
|
|
|
|
|
Object o = xs::out(this); |
|
|
|
50
|
|
|
|
|
|
|
185
|
246
|
50
|
|
|
|
|
auto sub = o.method("log_format"); |
|
|
|
100
|
|
|
|
|
|
|
186
|
123
|
100
|
|
|
|
|
if (!sub) return ILogger::log_format(msg, i, fmt); |
|
|
|
50
|
|
|
|
|
|
|
187
|
123
|
50
|
|
|
|
|
sub.call(o.ref(), xs::out(msg), xs::out(i.level), xs::out(i.module->name()), xs::out(i.file), xs::out(i.line), xs::out(i.func), xs::out(&fmt)); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
1
|
|
|
|
|
|
void log (const string& msg, const Info& info) override { |
|
191
|
1
|
50
|
|
|
|
|
if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread"); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
192
|
2
|
50
|
|
|
|
|
Object o = xs::out(this); |
|
|
|
50
|
|
|
|
|
|
|
193
|
1
|
50
|
|
|
|
|
o.call("log", xs::out(msg), xs::out(info.level)); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
194
|
1
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
100
|
50
|
|
|
|
|
~PerlObjectLogger () { Backref::dtor(); } |
|
197
|
|
|
|
|
|
|
}; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
struct NoWarningsGuard { |
|
200
|
7
|
|
|
|
|
|
NoWarningsGuard (bool enabled) : _enabled(enabled), _cop_warnings(), _dowarn() { |
|
201
|
7
|
100
|
|
|
|
|
if (!_enabled) return; |
|
202
|
1
|
|
|
|
|
|
_cop_warnings = PL_curcop->cop_warnings; |
|
203
|
1
|
|
|
|
|
|
_dowarn = PL_dowarn; |
|
204
|
1
|
|
|
|
|
|
PL_curcop->cop_warnings = pWARN_STD; |
|
205
|
1
|
|
|
|
|
|
PL_dowarn &= ~G_WARN_ON; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
6
|
|
|
|
|
|
~NoWarningsGuard () { |
|
209
|
5
|
100
|
|
|
|
|
if (!_enabled) return; |
|
210
|
1
|
|
|
|
|
|
PL_curcop->cop_warnings = _cop_warnings; |
|
211
|
1
|
|
|
|
|
|
PL_dowarn = _dowarn; |
|
212
|
5
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
private: |
|
215
|
|
|
|
|
|
|
bool _enabled; |
|
216
|
|
|
|
|
|
|
decltype(PL_curcop->cop_warnings) _cop_warnings; |
|
217
|
|
|
|
|
|
|
U8 _dowarn; |
|
218
|
|
|
|
|
|
|
}; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
namespace xs { |
|
221
|
|
|
|
|
|
|
template struct Typemap : Typemap {}; |
|
222
|
|
|
|
|
|
|
template struct Typemap : Typemap {}; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
#undef PANDA_LOG_CODE_POINT |
|
225
|
|
|
|
|
|
|
#define PANDA_LOG_CODE_POINT make_code_point() |
|
226
|
138
|
|
|
|
|
|
static inline CV* get_context_sub () { |
|
227
|
138
|
|
|
|
|
|
int depth = 0; |
|
228
|
138
|
50
|
|
|
|
|
auto ctx = caller_cx(depth, nullptr); |
|
229
|
139
|
100
|
|
|
|
|
while (ctx) { |
|
230
|
138
|
100
|
|
|
|
|
if (CxTYPE(ctx) == CXt_SUB) return ctx->blk_sub.cv; |
|
231
|
1
|
50
|
|
|
|
|
ctx = caller_cx(++depth, nullptr); |
|
232
|
|
|
|
|
|
|
} |
|
233
|
138
|
|
|
|
|
|
return nullptr; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
138
|
|
|
|
|
|
static inline CodePoint make_code_point () { |
|
236
|
138
|
|
|
|
|
|
auto cop = PL_curcop; |
|
237
|
|
|
|
|
|
|
|
|
238
|
138
|
|
|
|
|
|
string_view func; |
|
239
|
138
|
50
|
|
|
|
|
auto cv = get_context_sub(); |
|
240
|
138
|
100
|
|
|
|
|
if (cv) { |
|
241
|
137
|
50
|
|
|
|
|
GV* gv = CvGV(cv); |
|
242
|
137
|
50
|
|
|
|
|
if (gv) func = string_view(GvNAME(gv), GvNAMELEN(gv)); |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
138
|
50
|
|
|
|
|
return CodePoint{CopFILE(cop), CopLINE(cop), func}; |
|
246
|
|
|
|
|
|
|
} |
|
247
|
140
|
|
|
|
|
|
static inline Sv format_args (SV** args, int items) { |
|
248
|
140
|
100
|
|
|
|
|
if (!items) return Simple(default_message); |
|
|
|
50
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
|
250
|
115
|
100
|
|
|
|
|
if (items == 1) { |
|
251
|
216
|
|
|
|
|
|
Sv arg(args[0]); |
|
252
|
108
|
100
|
|
|
|
|
if (arg.is_simple()) { return arg; } |
|
253
|
4
|
50
|
|
|
|
|
else { return Simple(SvPV_nolen(args[0])); } |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
145
|
|
|
|
|
|
NoWarningsGuard g(no_format_warnings); (void)g; |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
STRLEN patlen; |
|
259
|
7
|
50
|
|
|
|
|
auto pat = SvPV(args[0], patlen); |
|
|
|
0
|
|
|
|
|
|
|
260
|
12
|
50
|
|
|
|
|
Sv ret = Simple::create(patlen * 1.5); |
|
261
|
7
|
|
|
|
|
|
bool stub = false; |
|
262
|
7
|
50
|
|
|
|
|
sv_vcatpvfn(ret, pat, patlen, nullptr, args + 1, items - 1, &stub); |
|
263
|
5
|
|
|
|
|
|
return ret; |
|
264
|
|
|
|
|
|
|
} |
|
265
|
168
|
|
|
|
|
|
static inline void peep_args (SV**& args, I32& items, const Module*& module, Sub& sub) { |
|
266
|
168
|
100
|
|
|
|
|
if (items && SvROK(args[0])) { |
|
|
|
100
|
|
|
|
|
|
|
267
|
55
|
|
|
|
|
|
auto first = SvRV(args[0]); |
|
268
|
55
|
50
|
|
|
|
|
if (has_module(first)) { |
|
|
|
100
|
|
|
|
|
|
|
269
|
48
|
50
|
|
|
|
|
module = xs::in(first); |
|
270
|
48
|
|
|
|
|
|
++args; |
|
271
|
48
|
|
|
|
|
|
--items; |
|
272
|
|
|
|
|
|
|
} |
|
273
|
7
|
100
|
|
|
|
|
else if (SvTYPE(first) == SVt_PVCV) { |
|
274
|
5
|
50
|
|
|
|
|
if (items > 1) throw exception("no arguments should follow subref when logging"); |
|
275
|
55
|
50
|
|
|
|
|
sub = first; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
|
|
279
|
168
|
100
|
|
|
|
|
if (!module) module = resolve_module(0); // auto detect module by namespace |
|
280
|
168
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
template |
|
282
|
140
|
|
|
|
|
|
void forward(Log&& log, SV**& args, I32& items, Sub& sub) { |
|
283
|
278
|
|
|
|
|
|
Simple msg; |
|
284
|
140
|
100
|
|
|
|
|
if (sub) { |
|
285
|
10
|
50
|
|
|
|
|
Sv ret = sub.call(); |
|
286
|
5
|
|
|
|
|
|
SV* sv = ret; |
|
287
|
5
|
50
|
|
|
|
|
msg = format_args(&sv, 1); |
|
|
|
50
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
else { |
|
290
|
135
|
50
|
|
|
|
|
msg = format_args(args, items); |
|
|
|
50
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
} |
|
292
|
138
|
50
|
|
|
|
|
log << msg.as_string(); |
|
|
|
50
|
|
|
|
|
|
|
293
|
138
|
|
|
|
|
|
} |
|
294
|
168
|
|
|
|
|
|
static void xslog (Level level, SV** args, I32 items) { |
|
295
|
168
|
|
|
|
|
|
const Module* module = nullptr; |
|
296
|
334
|
|
|
|
|
|
Sub sub; |
|
297
|
168
|
50
|
|
|
|
|
peep_args(args, items, module, sub); |
|
298
|
586
|
50
|
|
|
|
|
panda_log(level, *module, [&]{ forward(log, args, items, sub); }); |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
299
|
166
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
|
|
302
|
62
|
|
|
|
|
|
XS_EUPXS(XS_XLog_set_level) { xs::throw_guard(cv, [=]() |
|
303
|
|
|
|
|
|
|
{ |
|
304
|
31
|
|
|
|
|
|
dVAR; dXSARGS; |
|
305
|
31
|
50
|
|
|
|
|
if (items < 1 || items > 2) |
|
|
|
50
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "level, module= {}"); |
|
307
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
308
|
31
|
|
|
|
|
|
SP -= items; |
|
309
|
|
|
|
|
|
|
{ |
|
310
|
31
|
50
|
|
|
|
|
Level level = xs::in(ST(0)); |
|
311
|
|
|
|
|
|
|
; |
|
312
|
31
|
|
|
|
|
|
string_view module; |
|
313
|
|
|
|
|
|
|
|
|
314
|
31
|
50
|
|
|
|
|
if (items < 2) |
|
315
|
31
|
|
|
|
|
|
module = {}; |
|
316
|
|
|
|
|
|
|
else { |
|
317
|
|
|
|
|
|
|
{ STRLEN __module_len; |
|
318
|
0
|
0
|
|
|
|
|
const char* __module_buf = SvPV(ST(1), __module_len); |
|
|
|
0
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
module = decltype(module)(__module_buf, __module_len); } |
|
320
|
|
|
|
|
|
|
; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
#line 177 "./xs/XLog.xsi" |
|
323
|
|
|
|
|
|
|
set_level(level, module); |
|
324
|
|
|
|
|
|
|
#line 325 "XLog_xsgen.cc" |
|
325
|
31
|
|
|
|
|
|
PUTBACK; |
|
326
|
31
|
|
|
|
|
|
return; |
|
327
|
|
|
|
|
|
|
} |
|
328
|
31
|
50
|
|
|
|
|
}); } |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
|
|
332
|
110
|
|
|
|
|
|
XS_EUPXS(XS_XLog_set_logger) { xs::throw_guard(cv, [=]() |
|
333
|
|
|
|
|
|
|
{ |
|
334
|
55
|
|
|
|
|
|
dVAR; dXSARGS; |
|
335
|
55
|
50
|
|
|
|
|
if (items != 1) |
|
336
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "logger"); |
|
337
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
338
|
55
|
|
|
|
|
|
SP -= items; |
|
339
|
|
|
|
|
|
|
{ |
|
340
|
110
|
50
|
|
|
|
|
ILoggerSP logger = xs::in(ST(0)); |
|
341
|
|
|
|
|
|
|
; |
|
342
|
|
|
|
|
|
|
#line 179 "./xs/XLog.xsi" |
|
343
|
|
|
|
|
|
|
set_logger(logger); |
|
344
|
|
|
|
|
|
|
#line 345 "XLog_xsgen.cc" |
|
345
|
55
|
|
|
|
|
|
PUTBACK; |
|
346
|
110
|
|
|
|
|
|
return; |
|
347
|
|
|
|
|
|
|
} |
|
348
|
55
|
50
|
|
|
|
|
}); } |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
|
352
|
104
|
|
|
|
|
|
XS_EUPXS(XS_XLog_set_formatter) { xs::throw_guard(cv, [=]() |
|
353
|
|
|
|
|
|
|
{ |
|
354
|
52
|
|
|
|
|
|
dVAR; dXSARGS; |
|
355
|
52
|
|
|
|
|
|
dXSI32; |
|
356
|
52
|
50
|
|
|
|
|
if (items != 1) |
|
357
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "fmt"); |
|
358
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
359
|
52
|
|
|
|
|
|
SP -= items; |
|
360
|
|
|
|
|
|
|
{ |
|
361
|
104
|
50
|
|
|
|
|
IFormatterSP fmt = xs::in(ST(0)); |
|
362
|
|
|
|
|
|
|
; |
|
363
|
|
|
|
|
|
|
#line 182 "./xs/XLog.xsi" |
|
364
|
|
|
|
|
|
|
(void)ix; |
|
365
|
|
|
|
|
|
|
set_formatter(fmt); |
|
366
|
|
|
|
|
|
|
#line 367 "XLog_xsgen.cc" |
|
367
|
52
|
|
|
|
|
|
PUTBACK; |
|
368
|
104
|
|
|
|
|
|
return; |
|
369
|
|
|
|
|
|
|
} |
|
370
|
52
|
50
|
|
|
|
|
}); } |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
|
374
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog_get_logger) { xs::throw_guard(cv, [=]() |
|
375
|
|
|
|
|
|
|
{ |
|
376
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
377
|
1
|
50
|
|
|
|
|
if (items != 0) |
|
378
|
0
|
|
|
|
|
|
croak_xs_usage(cv, ""); |
|
379
|
|
|
|
|
|
|
{ |
|
380
|
1
|
|
|
|
|
|
ILoggerSP RETVAL; |
|
381
|
|
|
|
|
|
|
#line 186 "./xs/XLog.xsi" |
|
382
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
383
|
|
|
|
|
|
|
RETVAL = get_logger(); |
|
384
|
|
|
|
|
|
|
#line 385 "XLog_xsgen.cc" |
|
385
|
|
|
|
|
|
|
{ |
|
386
|
|
|
|
|
|
|
SV * RETVALSV; |
|
387
|
1
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
388
|
1
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
389
|
1
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
390
|
|
|
|
|
|
|
} |
|
391
|
|
|
|
|
|
|
} |
|
392
|
1
|
|
|
|
|
|
XSRETURN(1); |
|
393
|
1
|
50
|
|
|
|
|
}); } |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
|
|
397
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog_get_formatter) { xs::throw_guard(cv, [=]() |
|
398
|
|
|
|
|
|
|
{ |
|
399
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
400
|
1
|
50
|
|
|
|
|
if (items != 0) |
|
401
|
0
|
|
|
|
|
|
croak_xs_usage(cv, ""); |
|
402
|
|
|
|
|
|
|
{ |
|
403
|
1
|
|
|
|
|
|
IFormatterSP RETVAL; |
|
404
|
|
|
|
|
|
|
#line 188 "./xs/XLog.xsi" |
|
405
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
406
|
|
|
|
|
|
|
RETVAL = get_formatter(); |
|
407
|
|
|
|
|
|
|
#line 408 "XLog_xsgen.cc" |
|
408
|
|
|
|
|
|
|
{ |
|
409
|
|
|
|
|
|
|
SV * RETVALSV; |
|
410
|
1
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
411
|
1
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
412
|
1
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
} |
|
415
|
1
|
|
|
|
|
|
XSRETURN(1); |
|
416
|
1
|
50
|
|
|
|
|
}); } |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
|
|
420
|
6
|
|
|
|
|
|
XS_EUPXS(XS_XLog_get_module) { xs::throw_guard(cv, [=]() |
|
421
|
|
|
|
|
|
|
{ |
|
422
|
3
|
|
|
|
|
|
dVAR; dXSARGS; |
|
423
|
3
|
50
|
|
|
|
|
if (items != 1) |
|
424
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "name"); |
|
425
|
|
|
|
|
|
|
{ |
|
426
|
|
|
|
|
|
|
Module * RETVAL; |
|
427
|
3
|
|
|
|
|
|
string_view name; |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
{ STRLEN __name_len; |
|
430
|
3
|
50
|
|
|
|
|
const char* __name_buf = SvPV(ST(0), __name_len); |
|
|
|
0
|
|
|
|
|
|
|
431
|
3
|
|
|
|
|
|
name = decltype(name)(__name_buf, __name_len); } |
|
432
|
|
|
|
|
|
|
; |
|
433
|
|
|
|
|
|
|
#line 190 "./xs/XLog.xsi" |
|
434
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
435
|
|
|
|
|
|
|
RETVAL = get_module(name); |
|
436
|
|
|
|
|
|
|
#line 437 "XLog_xsgen.cc" |
|
437
|
|
|
|
|
|
|
{ |
|
438
|
|
|
|
|
|
|
SV * RETVALSV; |
|
439
|
3
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
440
|
3
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
441
|
3
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
442
|
|
|
|
|
|
|
} |
|
443
|
|
|
|
|
|
|
} |
|
444
|
3
|
|
|
|
|
|
XSRETURN(1); |
|
445
|
3
|
50
|
|
|
|
|
}); } |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
|
|
449
|
128
|
|
|
|
|
|
XS_EUPXS(XS_XLog_log) { xs::throw_guard(cv, [=]() |
|
450
|
|
|
|
|
|
|
{ |
|
451
|
64
|
|
|
|
|
|
dVAR; dXSARGS; |
|
452
|
64
|
50
|
|
|
|
|
if (items < 1) |
|
453
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "level, ..."); |
|
454
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
455
|
64
|
|
|
|
|
|
SP -= items; |
|
456
|
|
|
|
|
|
|
{ |
|
457
|
64
|
|
|
|
|
|
Level level = xs::in(ST(0)); |
|
458
|
|
|
|
|
|
|
; |
|
459
|
|
|
|
|
|
|
#line 193 "./xs/XLog.xsi" |
|
460
|
|
|
|
|
|
|
xslog(level, &ST(1), items-1); |
|
461
|
|
|
|
|
|
|
if (!(PL_op->op_spare & 1)) xlog::optimize(); |
|
462
|
|
|
|
|
|
|
#line 463 "XLog_xsgen.cc" |
|
463
|
64
|
|
|
|
|
|
PUTBACK; |
|
464
|
64
|
|
|
|
|
|
return; |
|
465
|
|
|
|
|
|
|
} |
|
466
|
64
|
50
|
|
|
|
|
}); } |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
|
470
|
40
|
|
|
|
|
|
XS_EUPXS(XS_XLog_resolve_module) { xs::throw_guard(cv, [=]() |
|
471
|
|
|
|
|
|
|
{ |
|
472
|
20
|
|
|
|
|
|
dVAR; dXSARGS; |
|
473
|
20
|
50
|
|
|
|
|
if (items < 0 || items > 1) |
|
|
|
50
|
|
|
|
|
|
|
474
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "depth= 0"); |
|
475
|
|
|
|
|
|
|
{ |
|
476
|
|
|
|
|
|
|
Module * RETVAL; |
|
477
|
|
|
|
|
|
|
size_t depth; |
|
478
|
|
|
|
|
|
|
|
|
479
|
20
|
50
|
|
|
|
|
if (items < 1) |
|
480
|
0
|
|
|
|
|
|
depth = 0; |
|
481
|
|
|
|
|
|
|
else { |
|
482
|
40
|
|
|
|
|
|
depth = (size_t)SvUV(ST(0)) |
|
483
|
20
|
50
|
|
|
|
|
; |
|
|
|
50
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
#line 198 "./xs/XLog.xsi" |
|
486
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
487
|
|
|
|
|
|
|
RETVAL = resolve_module(depth); |
|
488
|
|
|
|
|
|
|
#line 489 "XLog_xsgen.cc" |
|
489
|
|
|
|
|
|
|
{ |
|
490
|
|
|
|
|
|
|
SV * RETVALSV; |
|
491
|
20
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
492
|
20
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
493
|
20
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
} |
|
496
|
20
|
|
|
|
|
|
XSRETURN(1); |
|
497
|
20
|
50
|
|
|
|
|
}); } |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
|
|
501
|
4
|
|
|
|
|
|
XS_EUPXS(XS_XLog_disable_format_warnings) { xs::throw_guard(cv, [=]() |
|
502
|
|
|
|
|
|
|
{ |
|
503
|
2
|
|
|
|
|
|
dVAR; dXSARGS; |
|
504
|
2
|
|
|
|
|
|
dXSI32; |
|
505
|
2
|
50
|
|
|
|
|
if (items != 0) |
|
506
|
0
|
|
|
|
|
|
croak_xs_usage(cv, ""); |
|
507
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
508
|
2
|
|
|
|
|
|
SP -= items; |
|
509
|
|
|
|
|
|
|
{ |
|
510
|
|
|
|
|
|
|
#line 202 "./xs/XLog.xsi" |
|
511
|
|
|
|
|
|
|
no_format_warnings = !ix; |
|
512
|
|
|
|
|
|
|
#line 513 "XLog_xsgen.cc" |
|
513
|
2
|
|
|
|
|
|
PUTBACK; |
|
514
|
2
|
|
|
|
|
|
return; |
|
515
|
|
|
|
|
|
|
} |
|
516
|
2
|
50
|
|
|
|
|
}); } |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
|
|
520
|
208
|
|
|
|
|
|
XS_EUPXS(XS_XLog___logXXX) { xs::throw_guard(cv, [=]() |
|
521
|
|
|
|
|
|
|
{ |
|
522
|
104
|
|
|
|
|
|
dVAR; dXSARGS; |
|
523
|
104
|
|
|
|
|
|
dXSI32; |
|
524
|
|
|
|
|
|
|
PERL_UNUSED_VAR(cv); /* -W */ |
|
525
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
526
|
104
|
|
|
|
|
|
SP -= items; |
|
527
|
|
|
|
|
|
|
{ |
|
528
|
|
|
|
|
|
|
#line 206 "./xs/XLog.xsi" |
|
529
|
|
|
|
|
|
|
Level level = Level((int)Level::VerboseDebug + ix); |
|
530
|
|
|
|
|
|
|
xslog(level, &ST(0), items); |
|
531
|
|
|
|
|
|
|
if (!(PL_op->op_spare & 1)) xlog::optimize(level); |
|
532
|
|
|
|
|
|
|
#line 533 "XLog_xsgen.cc" |
|
533
|
102
|
|
|
|
|
|
PUTBACK; |
|
534
|
102
|
|
|
|
|
|
return; |
|
535
|
|
|
|
|
|
|
} |
|
536
|
104
|
50
|
|
|
|
|
}); } |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/XLog.xsi' */ |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/Logger.xsi' from 'XLog.xs' */ |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
|
|
546
|
50
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Logger_new) { xs::throw_guard(cv, [=]() |
|
547
|
|
|
|
|
|
|
{ |
|
548
|
25
|
|
|
|
|
|
dVAR; dXSARGS; |
|
549
|
25
|
50
|
|
|
|
|
if (items != 1) |
|
550
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "CLASS"); |
|
551
|
|
|
|
|
|
|
{ |
|
552
|
|
|
|
|
|
|
PerlObjectLogger * RETVAL; |
|
553
|
25
|
|
|
|
|
|
SV* CLASS = ST(0) |
|
554
|
|
|
|
|
|
|
; |
|
555
|
|
|
|
|
|
|
#line 9 "./xs/Logger.xsi" |
|
556
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
557
|
|
|
|
|
|
|
PROTO = CLASS; |
|
558
|
|
|
|
|
|
|
PROTO = Stash::from_name(CLASS).bless(Hash::create()); |
|
559
|
|
|
|
|
|
|
RETVAL = new PerlObjectLogger(); |
|
560
|
|
|
|
|
|
|
#line 561 "XLog_xsgen.cc" |
|
561
|
|
|
|
|
|
|
{ |
|
562
|
|
|
|
|
|
|
SV * RETVALSV; |
|
563
|
25
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
564
|
25
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
565
|
25
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
566
|
|
|
|
|
|
|
} |
|
567
|
|
|
|
|
|
|
} |
|
568
|
25
|
|
|
|
|
|
XSRETURN(1); |
|
569
|
25
|
50
|
|
|
|
|
}); } |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/Logger.xsi' */ |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/Formatter.xsi' from 'XLog.xs' */ |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
|
|
579
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Formatter_new) { xs::throw_guard(cv, [=]() |
|
580
|
|
|
|
|
|
|
{ |
|
581
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
582
|
1
|
50
|
|
|
|
|
if (items != 1) |
|
583
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "CLASS"); |
|
584
|
|
|
|
|
|
|
{ |
|
585
|
|
|
|
|
|
|
PerlObjectFormatter * RETVAL; |
|
586
|
1
|
|
|
|
|
|
SV* CLASS = ST(0) |
|
587
|
|
|
|
|
|
|
; |
|
588
|
|
|
|
|
|
|
#line 5 "./xs/Formatter.xsi" |
|
589
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
590
|
|
|
|
|
|
|
PROTO = CLASS; |
|
591
|
|
|
|
|
|
|
PROTO = Stash::from_name(CLASS).bless(Hash::create()); |
|
592
|
|
|
|
|
|
|
RETVAL = new PerlObjectFormatter(); |
|
593
|
|
|
|
|
|
|
#line 594 "XLog_xsgen.cc" |
|
594
|
|
|
|
|
|
|
{ |
|
595
|
|
|
|
|
|
|
SV * RETVALSV; |
|
596
|
1
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
597
|
1
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
598
|
1
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
599
|
|
|
|
|
|
|
} |
|
600
|
|
|
|
|
|
|
} |
|
601
|
1
|
|
|
|
|
|
XSRETURN(1); |
|
602
|
1
|
50
|
|
|
|
|
}); } |
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
static const char* DECORATOR_KEY = "_decorator"; |
|
605
|
|
|
|
|
|
|
// let it be only script basename, without file |
|
606
|
8
|
|
|
|
|
|
static string decorate_default(const char* name) { |
|
607
|
16
|
|
|
|
|
|
string in(name); |
|
608
|
8
|
50
|
|
|
|
|
auto pos = in.find_last_of("/\\"); |
|
609
|
8
|
50
|
|
|
|
|
if (pos == string::npos) { |
|
610
|
0
|
0
|
|
|
|
|
return in; |
|
611
|
|
|
|
|
|
|
} |
|
612
|
8
|
50
|
|
|
|
|
return in.substr(pos + 1); |
|
613
|
|
|
|
|
|
|
} |
|
614
|
|
|
|
|
|
|
static xs::Sv::payload_marker_t spy_$0_marker{}; |
|
615
|
1
|
|
|
|
|
|
static int spy_$0(pTHX_ SV* sv, MAGIC* mg) { |
|
616
|
1
|
50
|
|
|
|
|
if (mg->mg_virtual == &spy_$0_marker) { |
|
617
|
2
|
50
|
|
|
|
|
Stash stash("XLog::Formatter::Pattern"); |
|
618
|
2
|
50
|
|
|
|
|
auto decorator = stash.sub(DECORATOR_KEY); |
|
619
|
2
|
|
|
|
|
|
string $0; |
|
620
|
1
|
50
|
|
|
|
|
if (decorator) { |
|
621
|
2
|
50
|
|
|
|
|
auto decorated = decorator.call(sv); |
|
622
|
1
|
50
|
|
|
|
|
$0 = SvPV_nolen(decorated); |
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
else { |
|
625
|
0
|
0
|
|
|
|
|
$0 = decorate_default(SvPV_nolen(sv)); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
} |
|
627
|
1
|
|
|
|
|
|
set_program_name($0); |
|
628
|
|
|
|
|
|
|
} |
|
629
|
1
|
|
|
|
|
|
return 0; |
|
630
|
|
|
|
|
|
|
} |
|
631
|
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
|
|
633
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Formatter__Pattern_new) { xs::throw_guard(cv, [=]() |
|
634
|
|
|
|
|
|
|
{ |
|
635
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
636
|
1
|
50
|
|
|
|
|
if (items != 2) |
|
637
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "CLASS, fmt"); |
|
638
|
|
|
|
|
|
|
{ |
|
639
|
|
|
|
|
|
|
IFormatter * RETVAL; |
|
640
|
1
|
|
|
|
|
|
SV* CLASS = ST(0) |
|
641
|
|
|
|
|
|
|
; |
|
642
|
1
|
|
|
|
|
|
string_view fmt; |
|
643
|
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
{ STRLEN __fmt_len; |
|
645
|
1
|
50
|
|
|
|
|
const char* __fmt_buf = SvPV(ST(1), __fmt_len); |
|
|
|
0
|
|
|
|
|
|
|
646
|
1
|
|
|
|
|
|
fmt = decltype(fmt)(__fmt_buf, __fmt_len); } |
|
647
|
|
|
|
|
|
|
; |
|
648
|
|
|
|
|
|
|
#line 67 "./xs/Formatter.xsi" |
|
649
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
650
|
|
|
|
|
|
|
PROTO = CLASS; |
|
651
|
|
|
|
|
|
|
RETVAL = new PatternFormatter(fmt); |
|
652
|
|
|
|
|
|
|
#line 653 "XLog_xsgen.cc" |
|
653
|
|
|
|
|
|
|
{ |
|
654
|
|
|
|
|
|
|
SV * RETVALSV; |
|
655
|
1
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
656
|
1
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
657
|
1
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
} |
|
660
|
1
|
|
|
|
|
|
XSRETURN(1); |
|
661
|
1
|
50
|
|
|
|
|
}); } |
|
662
|
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
|
|
665
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Formatter__Pattern_set_program_decorator) { xs::throw_guard(cv, [=]() |
|
666
|
|
|
|
|
|
|
{ |
|
667
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
668
|
1
|
50
|
|
|
|
|
if (items != 1) |
|
669
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "callback"); |
|
670
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
671
|
1
|
|
|
|
|
|
SP -= items; |
|
672
|
|
|
|
|
|
|
{ |
|
673
|
2
|
50
|
|
|
|
|
Sub callback = ST(0); |
|
674
|
1
|
50
|
|
|
|
|
if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference" |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
675
|
0
|
|
|
|
|
|
; |
|
676
|
|
|
|
|
|
|
#line 70 "./xs/Formatter.xsi" |
|
677
|
|
|
|
|
|
|
Stash stash("XLog::Formatter::Pattern"); |
|
678
|
|
|
|
|
|
|
stash.store(DECORATOR_KEY, callback); |
|
679
|
|
|
|
|
|
|
#line 680 "XLog_xsgen.cc" |
|
680
|
1
|
|
|
|
|
|
PUTBACK; |
|
681
|
2
|
|
|
|
|
|
return; |
|
682
|
|
|
|
|
|
|
} |
|
683
|
1
|
50
|
|
|
|
|
}); } |
|
684
|
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/Formatter.xsi' */ |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/Module.xsi' from 'XLog.xs' */ |
|
690
|
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
|
|
693
|
48
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_new) { xs::throw_guard(cv, [=]() |
|
694
|
|
|
|
|
|
|
{ |
|
695
|
24
|
|
|
|
|
|
dVAR; dXSARGS; |
|
696
|
24
|
50
|
|
|
|
|
if (items < 2 || items > 4) |
|
|
|
50
|
|
|
|
|
|
|
697
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "cls, name, arg1= {}, arg2= {}"); |
|
698
|
|
|
|
|
|
|
{ |
|
699
|
48
|
|
|
|
|
|
Sv RETVAL; |
|
700
|
24
|
|
|
|
|
|
SV* cls = ST(0) |
|
701
|
|
|
|
|
|
|
; |
|
702
|
48
|
50
|
|
|
|
|
string name; |
|
703
|
48
|
50
|
|
|
|
|
Sv arg1; |
|
704
|
48
|
50
|
|
|
|
|
Sv arg2; |
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
{ STRLEN __name_len; |
|
707
|
24
|
50
|
|
|
|
|
const char* __name_buf = SvPV(ST(1), __name_len); |
|
|
|
0
|
|
|
|
|
|
|
708
|
24
|
50
|
|
|
|
|
name.assign(__name_buf, __name_len); } |
|
709
|
|
|
|
|
|
|
; |
|
710
|
|
|
|
|
|
|
|
|
711
|
24
|
100
|
|
|
|
|
if (items < 3) |
|
712
|
8
|
|
|
|
|
|
arg1 = {}; |
|
713
|
|
|
|
|
|
|
else { |
|
714
|
16
|
|
|
|
|
|
arg1 = ST(2) |
|
715
|
16
|
50
|
|
|
|
|
; |
|
716
|
|
|
|
|
|
|
} |
|
717
|
|
|
|
|
|
|
|
|
718
|
24
|
100
|
|
|
|
|
if (items < 4) |
|
719
|
23
|
|
|
|
|
|
arg2 = {}; |
|
720
|
|
|
|
|
|
|
else { |
|
721
|
1
|
|
|
|
|
|
arg2 = ST(3) |
|
722
|
1
|
50
|
|
|
|
|
; |
|
723
|
|
|
|
|
|
|
} |
|
724
|
|
|
|
|
|
|
#line 7 "./xs/Module.xsi" |
|
725
|
|
|
|
|
|
|
--items; |
|
726
|
|
|
|
|
|
|
Module* module; |
|
727
|
|
|
|
|
|
|
if (items == 1) { |
|
728
|
|
|
|
|
|
|
module = new Module(name); |
|
729
|
|
|
|
|
|
|
} |
|
730
|
|
|
|
|
|
|
else if (items == 2) { |
|
731
|
|
|
|
|
|
|
if (!arg1.defined() || arg1.is_object_ref()) module = new Module(name, xs::in(arg1)); |
|
732
|
|
|
|
|
|
|
else module = new Module(name, xs::in(arg1)); |
|
733
|
|
|
|
|
|
|
} else { |
|
734
|
|
|
|
|
|
|
module = new Module(name, xs::in(arg1), xs::in(arg2)); |
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
// Module* has non-owning ptr typemap. In case of creating object from perl we must switch to "owning" behaviour |
|
738
|
|
|
|
|
|
|
// so we need to hook sv destruction and delete the object if we created it in this method. |
|
739
|
|
|
|
|
|
|
static Sv::payload_marker_t module_dtor_marker; |
|
740
|
|
|
|
|
|
|
module_dtor_marker.svt_free = [](pTHX_ SV*, MAGIC* mg) { |
|
741
|
|
|
|
|
|
|
delete (Module*)mg->mg_ptr; |
|
742
|
|
|
|
|
|
|
return 0; |
|
743
|
|
|
|
|
|
|
}; |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
Object o = xs::out(module, cls); |
|
746
|
|
|
|
|
|
|
o.payload_attach(module, &module_dtor_marker); |
|
747
|
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
RETVAL = o.ref(); |
|
749
|
|
|
|
|
|
|
#line 750 "XLog_xsgen.cc" |
|
750
|
|
|
|
|
|
|
{ |
|
751
|
|
|
|
|
|
|
SV * RETVALSV; |
|
752
|
24
|
|
|
|
|
|
RETVALSV = NULL; |
|
753
|
24
|
50
|
|
|
|
|
if (!RETVAL) XSRETURN_UNDEF; |
|
754
|
24
|
50
|
|
|
|
|
if (RETVAL.is_scalar()) RETVALSV = RETVAL.detach(); |
|
|
|
50
|
|
|
|
|
|
|
755
|
0
|
|
|
|
|
|
else switch (RETVAL.type()) { |
|
756
|
0
|
0
|
|
|
|
|
case SVt_PVAV: XSRETURN(xs::Array(RETVAL.get()).push_on_stack(MARK)); |
|
|
|
0
|
|
|
|
|
|
|
757
|
0
|
0
|
|
|
|
|
case SVt_PVHV: XSRETURN(xs::Hash(RETVAL.get()).push_on_stack(MARK)); |
|
|
|
0
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
case SVt_PVCV: |
|
759
|
|
|
|
|
|
|
case SVt_PVIO: |
|
760
|
0
|
0
|
|
|
|
|
RETVALSV = newRV_noinc(RETVAL.detach()); |
|
761
|
0
|
|
|
|
|
|
break; |
|
762
|
0
|
|
|
|
|
|
default: throw "unknown type of Sv to return"; |
|
763
|
|
|
|
|
|
|
} |
|
764
|
24
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
765
|
24
|
50
|
|
|
|
|
ST(0) = RETVALSV; |
|
766
|
|
|
|
|
|
|
} |
|
767
|
|
|
|
|
|
|
} |
|
768
|
24
|
|
|
|
|
|
XSRETURN(1); |
|
769
|
24
|
50
|
|
|
|
|
}); } |
|
770
|
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
|
|
773
|
8
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_name) { xs::throw_guard(cv, [=]() |
|
774
|
|
|
|
|
|
|
{ |
|
775
|
4
|
|
|
|
|
|
dVAR; dXSARGS; |
|
776
|
4
|
50
|
|
|
|
|
if (items != 1) |
|
777
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS"); |
|
778
|
|
|
|
|
|
|
{ |
|
779
|
8
|
|
|
|
|
|
string RETVAL; |
|
780
|
4
|
50
|
|
|
|
|
dXSTARG; |
|
|
|
0
|
|
|
|
|
|
|
781
|
4
|
50
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
; |
|
783
|
|
|
|
|
|
|
#line 33 "./xs/Module.xsi" |
|
784
|
|
|
|
|
|
|
RETVAL = THIS->name(); |
|
785
|
|
|
|
|
|
|
#line 786 "XLog_xsgen.cc" |
|
786
|
4
|
50
|
|
|
|
|
XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length()); |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
} |
|
788
|
4
|
|
|
|
|
|
XSRETURN(1); |
|
789
|
4
|
50
|
|
|
|
|
}); } |
|
790
|
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
|
|
793
|
10
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_level) { xs::throw_guard(cv, [=]() |
|
794
|
|
|
|
|
|
|
{ |
|
795
|
5
|
|
|
|
|
|
dVAR; dXSARGS; |
|
796
|
5
|
50
|
|
|
|
|
if (items != 1) |
|
797
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS"); |
|
798
|
|
|
|
|
|
|
{ |
|
799
|
|
|
|
|
|
|
Level RETVAL; |
|
800
|
5
|
50
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
; |
|
802
|
|
|
|
|
|
|
#line 35 "./xs/Module.xsi" |
|
803
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
804
|
|
|
|
|
|
|
RETVAL = THIS->level(); |
|
805
|
|
|
|
|
|
|
#line 806 "XLog_xsgen.cc" |
|
806
|
|
|
|
|
|
|
{ |
|
807
|
|
|
|
|
|
|
SV * RETVALSV; |
|
808
|
5
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
809
|
5
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
810
|
5
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
811
|
|
|
|
|
|
|
} |
|
812
|
|
|
|
|
|
|
} |
|
813
|
5
|
|
|
|
|
|
XSRETURN(1); |
|
814
|
5
|
50
|
|
|
|
|
}); } |
|
815
|
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
|
|
818
|
0
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_passthrough) { xs::throw_guard(cv, [=]() |
|
819
|
|
|
|
|
|
|
{ |
|
820
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
|
821
|
0
|
0
|
|
|
|
|
if (items != 1) |
|
822
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS"); |
|
823
|
|
|
|
|
|
|
{ |
|
824
|
|
|
|
|
|
|
bool RETVAL; |
|
825
|
0
|
0
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
; |
|
827
|
|
|
|
|
|
|
#line 37 "./xs/Module.xsi" |
|
828
|
|
|
|
|
|
|
RETVAL = THIS->passthrough(); |
|
829
|
|
|
|
|
|
|
#line 830 "XLog_xsgen.cc" |
|
830
|
0
|
0
|
|
|
|
|
ST(0) = boolSV(RETVAL); |
|
831
|
|
|
|
|
|
|
} |
|
832
|
0
|
|
|
|
|
|
XSRETURN(1); |
|
833
|
0
|
0
|
|
|
|
|
}); } |
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
|
|
837
|
4
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_set_level) { xs::throw_guard(cv, [=]() |
|
838
|
|
|
|
|
|
|
{ |
|
839
|
2
|
|
|
|
|
|
dVAR; dXSARGS; |
|
840
|
2
|
50
|
|
|
|
|
if (items != 2) |
|
841
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS, level"); |
|
842
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
843
|
2
|
|
|
|
|
|
SP -= items; |
|
844
|
|
|
|
|
|
|
{ |
|
845
|
2
|
50
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
; |
|
847
|
2
|
|
|
|
|
|
Level level = xs::in(ST(1)); |
|
848
|
|
|
|
|
|
|
; |
|
849
|
|
|
|
|
|
|
#line 39 "./xs/Module.xsi" |
|
850
|
|
|
|
|
|
|
THIS->set_level(level); |
|
851
|
|
|
|
|
|
|
#line 852 "XLog_xsgen.cc" |
|
852
|
2
|
|
|
|
|
|
PUTBACK; |
|
853
|
2
|
|
|
|
|
|
return; |
|
854
|
|
|
|
|
|
|
} |
|
855
|
2
|
50
|
|
|
|
|
}); } |
|
856
|
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
|
|
859
|
8
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_set_logger) { xs::throw_guard(cv, [=]() |
|
860
|
|
|
|
|
|
|
{ |
|
861
|
4
|
|
|
|
|
|
dVAR; dXSARGS; |
|
862
|
4
|
50
|
|
|
|
|
if (items < 2 || items > 3) |
|
|
|
50
|
|
|
|
|
|
|
863
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS, logger, passthrough= false"); |
|
864
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
865
|
4
|
|
|
|
|
|
SP -= items; |
|
866
|
|
|
|
|
|
|
{ |
|
867
|
4
|
50
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
; |
|
869
|
8
|
50
|
|
|
|
|
ILoggerSP logger = xs::in(ST(1)); |
|
870
|
|
|
|
|
|
|
; |
|
871
|
|
|
|
|
|
|
bool passthrough; |
|
872
|
|
|
|
|
|
|
|
|
873
|
4
|
100
|
|
|
|
|
if (items < 3) |
|
874
|
3
|
|
|
|
|
|
passthrough = false; |
|
875
|
|
|
|
|
|
|
else { |
|
876
|
1
|
50
|
|
|
|
|
passthrough = (bool)SvTRUE(ST(2)) |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
877
|
1
|
|
|
|
|
|
; |
|
878
|
|
|
|
|
|
|
} |
|
879
|
|
|
|
|
|
|
#line 41 "./xs/Module.xsi" |
|
880
|
|
|
|
|
|
|
THIS->set_logger(logger, passthrough); |
|
881
|
|
|
|
|
|
|
#line 882 "XLog_xsgen.cc" |
|
882
|
4
|
|
|
|
|
|
PUTBACK; |
|
883
|
8
|
|
|
|
|
|
return; |
|
884
|
|
|
|
|
|
|
} |
|
885
|
4
|
50
|
|
|
|
|
}); } |
|
886
|
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
|
|
889
|
4
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_set_formatter) { xs::throw_guard(cv, [=]() |
|
890
|
|
|
|
|
|
|
{ |
|
891
|
2
|
|
|
|
|
|
dVAR; dXSARGS; |
|
892
|
2
|
50
|
|
|
|
|
if (items != 2) |
|
893
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS, formatter"); |
|
894
|
|
|
|
|
|
|
PERL_UNUSED_VAR(ax); /* -Wall */ |
|
895
|
2
|
|
|
|
|
|
SP -= items; |
|
896
|
|
|
|
|
|
|
{ |
|
897
|
2
|
50
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
; |
|
899
|
4
|
50
|
|
|
|
|
IFormatterSP formatter = xs::in(ST(1)); |
|
900
|
|
|
|
|
|
|
; |
|
901
|
|
|
|
|
|
|
#line 43 "./xs/Module.xsi" |
|
902
|
|
|
|
|
|
|
THIS->set_formatter(formatter); |
|
903
|
|
|
|
|
|
|
#line 904 "XLog_xsgen.cc" |
|
904
|
2
|
|
|
|
|
|
PUTBACK; |
|
905
|
4
|
|
|
|
|
|
return; |
|
906
|
|
|
|
|
|
|
} |
|
907
|
2
|
50
|
|
|
|
|
}); } |
|
908
|
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
|
|
911
|
0
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_get_logger) { xs::throw_guard(cv, [=]() |
|
912
|
|
|
|
|
|
|
{ |
|
913
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
|
914
|
0
|
0
|
|
|
|
|
if (items != 1) |
|
915
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS"); |
|
916
|
|
|
|
|
|
|
{ |
|
917
|
0
|
|
|
|
|
|
ILoggerSP RETVAL; |
|
918
|
0
|
0
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
; |
|
920
|
|
|
|
|
|
|
#line 45 "./xs/Module.xsi" |
|
921
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
922
|
|
|
|
|
|
|
RETVAL = THIS->get_logger(); |
|
923
|
|
|
|
|
|
|
#line 924 "XLog_xsgen.cc" |
|
924
|
|
|
|
|
|
|
{ |
|
925
|
|
|
|
|
|
|
SV * RETVALSV; |
|
926
|
0
|
0
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
927
|
0
|
0
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
928
|
0
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
929
|
|
|
|
|
|
|
} |
|
930
|
|
|
|
|
|
|
} |
|
931
|
0
|
|
|
|
|
|
XSRETURN(1); |
|
932
|
0
|
0
|
|
|
|
|
}); } |
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
|
|
936
|
0
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Module_get_formatter) { xs::throw_guard(cv, [=]() |
|
937
|
|
|
|
|
|
|
{ |
|
938
|
0
|
|
|
|
|
|
dVAR; dXSARGS; |
|
939
|
0
|
0
|
|
|
|
|
if (items != 1) |
|
940
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "THIS"); |
|
941
|
|
|
|
|
|
|
{ |
|
942
|
0
|
|
|
|
|
|
IFormatterSP RETVAL; |
|
943
|
0
|
0
|
|
|
|
|
Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS"; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
; |
|
945
|
|
|
|
|
|
|
#line 47 "./xs/Module.xsi" |
|
946
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
947
|
|
|
|
|
|
|
RETVAL = THIS->get_formatter(); |
|
948
|
|
|
|
|
|
|
#line 949 "XLog_xsgen.cc" |
|
949
|
|
|
|
|
|
|
{ |
|
950
|
|
|
|
|
|
|
SV * RETVALSV; |
|
951
|
0
|
0
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
952
|
0
|
0
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
953
|
0
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
954
|
|
|
|
|
|
|
} |
|
955
|
|
|
|
|
|
|
} |
|
956
|
0
|
|
|
|
|
|
XSRETURN(1); |
|
957
|
0
|
0
|
|
|
|
|
}); } |
|
958
|
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/Module.xsi' */ |
|
961
|
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/Console.xsi' from 'XLog.xs' */ |
|
964
|
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
#include |
|
966
|
2
|
0
|
|
|
|
|
struct XSConsoleLogger : ConsoleLogger { |
|
967
|
|
|
|
|
|
|
using ConsoleLogger::ConsoleLogger; |
|
968
|
|
|
|
|
|
|
|
|
969
|
1
|
|
|
|
|
|
void log (const string& msg, const Info&) override { |
|
970
|
2
|
50
|
|
|
|
|
Io io = PL_defoutgv; |
|
971
|
1
|
50
|
|
|
|
|
if (!io) return; |
|
972
|
1
|
|
|
|
|
|
auto fp = io.ofp(); |
|
973
|
1
|
50
|
|
|
|
|
if (!fp) return; |
|
974
|
1
|
50
|
|
|
|
|
PerlIO_write(fp, msg.data(), msg.length()); |
|
975
|
1
|
50
|
|
|
|
|
PerlIO_write(fp, "\n", 1); |
|
|
|
50
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
} |
|
977
|
|
|
|
|
|
|
}; |
|
978
|
|
|
|
|
|
|
namespace xs { |
|
979
|
|
|
|
|
|
|
template struct Typemap : Typemap { |
|
980
|
0
|
|
|
|
|
|
static string package () { return "XLog::Console"; } |
|
981
|
|
|
|
|
|
|
}; |
|
982
|
|
|
|
|
|
|
template <> struct Typemap : Typemap {}; |
|
983
|
|
|
|
|
|
|
} |
|
984
|
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
|
|
986
|
2
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Console_new) { xs::throw_guard(cv, [=]() |
|
987
|
|
|
|
|
|
|
{ |
|
988
|
1
|
|
|
|
|
|
dVAR; dXSARGS; |
|
989
|
1
|
50
|
|
|
|
|
if (items != 1) |
|
990
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "CLASS"); |
|
991
|
|
|
|
|
|
|
{ |
|
992
|
|
|
|
|
|
|
XSConsoleLogger * RETVAL; |
|
993
|
1
|
|
|
|
|
|
SV* CLASS = ST(0) |
|
994
|
|
|
|
|
|
|
; |
|
995
|
|
|
|
|
|
|
#line 31 "./xs/Console.xsi" |
|
996
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
997
|
|
|
|
|
|
|
PROTO = CLASS; |
|
998
|
|
|
|
|
|
|
RETVAL = new XSConsoleLogger(); |
|
999
|
|
|
|
|
|
|
#line 1000 "XLog_xsgen.cc" |
|
1000
|
|
|
|
|
|
|
{ |
|
1001
|
|
|
|
|
|
|
SV * RETVALSV; |
|
1002
|
1
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
1003
|
1
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
1004
|
1
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
1005
|
|
|
|
|
|
|
} |
|
1006
|
|
|
|
|
|
|
} |
|
1007
|
1
|
|
|
|
|
|
XSRETURN(1); |
|
1008
|
1
|
50
|
|
|
|
|
}); } |
|
1009
|
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/Console.xsi' */ |
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
/* INCLUDE: Including 'xs/Multi.xsi' from 'XLog.xs' */ |
|
1015
|
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
#include |
|
1017
|
|
|
|
|
|
|
namespace xs { |
|
1018
|
|
|
|
|
|
|
template <> struct Typemap : TypemapBase { |
|
1019
|
8
|
|
|
|
|
|
static MultiLogger::Channel in (const Hash& h) { |
|
1020
|
8
|
50
|
|
|
|
|
auto ret = MultiLogger::Channel(xs::in(h.fetch("logger"))); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1021
|
16
|
|
|
|
|
|
Sv val; |
|
1022
|
8
|
50
|
|
|
|
|
if ((val = h.fetch("min_level"))) ret.min_level = xs::in(val); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1023
|
8
|
50
|
|
|
|
|
if ((val = h.fetch("formatter"))) ret.formatter = xs::in(val); |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1024
|
8
|
50
|
|
|
|
|
if ((val = h.fetch("format")) && val.defined()) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1025
|
0
|
0
|
|
|
|
|
auto fmt = xs::in(val); |
|
1026
|
0
|
0
|
|
|
|
|
if (fmt.length()) ret.formatter = new PatternFormatter(fmt); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
} |
|
1028
|
16
|
|
|
|
|
|
return ret; |
|
1029
|
|
|
|
|
|
|
} |
|
1030
|
|
|
|
|
|
|
}; |
|
1031
|
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
template <> struct Typemap : Typemap { |
|
1033
|
0
|
|
|
|
|
|
static string package () { return "XLog::Multi"; } |
|
1034
|
|
|
|
|
|
|
}; |
|
1035
|
|
|
|
|
|
|
} |
|
1036
|
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
|
|
1038
|
4
|
|
|
|
|
|
XS_EUPXS(XS_XLog__Multi_new) { xs::throw_guard(cv, [=]() |
|
1039
|
|
|
|
|
|
|
{ |
|
1040
|
2
|
|
|
|
|
|
dVAR; dXSARGS; |
|
1041
|
2
|
50
|
|
|
|
|
if (items != 2) |
|
1042
|
0
|
|
|
|
|
|
croak_xs_usage(cv, "CLASS, list"); |
|
1043
|
|
|
|
|
|
|
{ |
|
1044
|
|
|
|
|
|
|
MultiLogger * RETVAL; |
|
1045
|
2
|
|
|
|
|
|
SV* CLASS = ST(0) |
|
1046
|
|
|
|
|
|
|
; |
|
1047
|
4
|
50
|
|
|
|
|
MultiLogger::Channels list = xs::in(ST(1)); |
|
1048
|
|
|
|
|
|
|
; |
|
1049
|
|
|
|
|
|
|
#line 31 "./xs/Multi.xsi" |
|
1050
|
|
|
|
|
|
|
xs::Sv PROTO; PERL_UNUSED_VAR(PROTO); |
|
1051
|
|
|
|
|
|
|
PROTO = CLASS; |
|
1052
|
|
|
|
|
|
|
RETVAL = new MultiLogger(list); |
|
1053
|
|
|
|
|
|
|
#line 1054 "XLog_xsgen.cc" |
|
1054
|
|
|
|
|
|
|
{ |
|
1055
|
|
|
|
|
|
|
SV * RETVALSV; |
|
1056
|
2
|
50
|
|
|
|
|
RETVALSV = xs::out(RETVAL, PROTO).detach(); |
|
1057
|
2
|
50
|
|
|
|
|
RETVALSV = sv_2mortal(RETVALSV); |
|
1058
|
2
|
|
|
|
|
|
ST(0) = RETVALSV; |
|
1059
|
|
|
|
|
|
|
} |
|
1060
|
|
|
|
|
|
|
} |
|
1061
|
2
|
|
|
|
|
|
XSRETURN(1); |
|
1062
|
2
|
50
|
|
|
|
|
}); } |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
/* INCLUDE: Returning to 'XLog.xs' from 'xs/Multi.xsi' */ |
|
1066
|
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
1068
|
|
|
|
|
|
|
extern "C" |
|
1069
|
|
|
|
|
|
|
#endif |
|
1070
|
|
|
|
|
|
|
|
|
1071
|
16
|
|
|
|
|
|
XS_EXTERNAL(boot_XLog) { xs::throw_guard(cv, [=]() mutable |
|
1072
|
|
|
|
|
|
|
{ |
|
1073
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
|
1074
|
|
|
|
|
|
|
dVAR; dXSARGS; |
|
1075
|
|
|
|
|
|
|
#else |
|
1076
|
8
|
50
|
|
|
|
|
dVAR; dXSBOOTARGSXSAPIVERCHK; |
|
|
|
50
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
#endif |
|
1078
|
|
|
|
|
|
|
#if (PERL_REVISION == 5 && PERL_VERSION < 9) |
|
1079
|
|
|
|
|
|
|
char* file = __FILE__; |
|
1080
|
|
|
|
|
|
|
#else |
|
1081
|
8
|
|
|
|
|
|
const char* file = __FILE__; |
|
1082
|
|
|
|
|
|
|
#endif |
|
1083
|
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
PERL_UNUSED_VAR(file); |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
PERL_UNUSED_VAR(cv); /* -W */ |
|
1087
|
|
|
|
|
|
|
PERL_UNUSED_VAR(items); /* -W */ |
|
1088
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
|
1089
|
|
|
|
|
|
|
XS_VERSION_BOOTCHECK; |
|
1090
|
|
|
|
|
|
|
# ifdef XS_APIVERSION_BOOTCHECK |
|
1091
|
|
|
|
|
|
|
XS_APIVERSION_BOOTCHECK; |
|
1092
|
|
|
|
|
|
|
# endif |
|
1093
|
|
|
|
|
|
|
#endif |
|
1094
|
|
|
|
|
|
|
|
|
1095
|
8
|
|
|
|
|
|
newXS_deffile("XLog::set_level", XS_XLog_set_level); |
|
1096
|
8
|
|
|
|
|
|
newXS_deffile("XLog::set_logger", XS_XLog_set_logger); |
|
1097
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::set_format", XS_XLog_set_formatter); |
|
1098
|
8
|
|
|
|
|
|
XSANY.any_i32 = 1; |
|
1099
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::set_formatter", XS_XLog_set_formatter); |
|
1100
|
8
|
|
|
|
|
|
XSANY.any_i32 = 0; |
|
1101
|
8
|
|
|
|
|
|
newXS_deffile("XLog::get_logger", XS_XLog_get_logger); |
|
1102
|
8
|
|
|
|
|
|
newXS_deffile("XLog::get_formatter", XS_XLog_get_formatter); |
|
1103
|
8
|
|
|
|
|
|
newXS_deffile("XLog::get_module", XS_XLog_get_module); |
|
1104
|
8
|
|
|
|
|
|
newXS_deffile("XLog::log", XS_XLog_log); |
|
1105
|
8
|
|
|
|
|
|
newXS_deffile("XLog::resolve_module", XS_XLog_resolve_module); |
|
1106
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::disable_format_warnings", XS_XLog_disable_format_warnings); |
|
1107
|
8
|
|
|
|
|
|
XSANY.any_i32 = 0; |
|
1108
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::enable_format_warnings", XS_XLog_disable_format_warnings); |
|
1109
|
8
|
|
|
|
|
|
XSANY.any_i32 = 1; |
|
1110
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::__logXXX", XS_XLog___logXXX); |
|
1111
|
8
|
|
|
|
|
|
XSANY.any_i32 = 0; |
|
1112
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::alert", XS_XLog___logXXX); |
|
1113
|
8
|
|
|
|
|
|
XSANY.any_i32 = 7; |
|
1114
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::critical", XS_XLog___logXXX); |
|
1115
|
8
|
|
|
|
|
|
XSANY.any_i32 = 6; |
|
1116
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::debug", XS_XLog___logXXX); |
|
1117
|
8
|
|
|
|
|
|
XSANY.any_i32 = 1; |
|
1118
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::emergency", XS_XLog___logXXX); |
|
1119
|
8
|
|
|
|
|
|
XSANY.any_i32 = 8; |
|
1120
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::error", XS_XLog___logXXX); |
|
1121
|
8
|
|
|
|
|
|
XSANY.any_i32 = 5; |
|
1122
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::info", XS_XLog___logXXX); |
|
1123
|
8
|
|
|
|
|
|
XSANY.any_i32 = 2; |
|
1124
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::notice", XS_XLog___logXXX); |
|
1125
|
8
|
|
|
|
|
|
XSANY.any_i32 = 3; |
|
1126
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::verbose_debug", XS_XLog___logXXX); |
|
1127
|
8
|
|
|
|
|
|
XSANY.any_i32 = 0; |
|
1128
|
8
|
|
|
|
|
|
cv = newXS_deffile("XLog::warning", XS_XLog___logXXX); |
|
1129
|
8
|
|
|
|
|
|
XSANY.any_i32 = 4; |
|
1130
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Logger::new", XS_XLog__Logger_new); |
|
1131
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Formatter::new", XS_XLog__Formatter_new); |
|
1132
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Formatter::Pattern::new", XS_XLog__Formatter__Pattern_new); |
|
1133
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Formatter::Pattern::set_program_decorator", XS_XLog__Formatter__Pattern_set_program_decorator); |
|
1134
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::new", XS_XLog__Module_new); |
|
1135
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::name", XS_XLog__Module_name); |
|
1136
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::level", XS_XLog__Module_level); |
|
1137
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::passthrough", XS_XLog__Module_passthrough); |
|
1138
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::set_level", XS_XLog__Module_set_level); |
|
1139
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::set_logger", XS_XLog__Module_set_logger); |
|
1140
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::set_formatter", XS_XLog__Module_set_formatter); |
|
1141
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::get_logger", XS_XLog__Module_get_logger); |
|
1142
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Module::get_formatter", XS_XLog__Module_get_formatter); |
|
1143
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Console::new", XS_XLog__Console_new); |
|
1144
|
8
|
|
|
|
|
|
newXS_deffile("XLog::Multi::new", XS_XLog__Multi_new); |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
/* Initialisation Section */ |
|
1147
|
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
#line 150 "./xs/XLog.xsi" |
|
1149
|
|
|
|
|
|
|
{ |
|
1150
|
|
|
|
|
|
|
Stash stash("XLog"); |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
xs::exp::create_constants(stash, { |
|
1153
|
|
|
|
|
|
|
{"VERBOSE_DEBUG", (int)Level::VerboseDebug}, |
|
1154
|
|
|
|
|
|
|
{"DEBUG", (int)Level::Debug}, |
|
1155
|
|
|
|
|
|
|
{"INFO", (int)Level::Info}, |
|
1156
|
|
|
|
|
|
|
{"NOTICE", (int)Level::Notice}, |
|
1157
|
|
|
|
|
|
|
{"WARNING", (int)Level::Warning}, |
|
1158
|
|
|
|
|
|
|
{"ERROR", (int)Level::Error}, |
|
1159
|
|
|
|
|
|
|
{"CRITICAL", (int)Level::Critical}, |
|
1160
|
|
|
|
|
|
|
{"ALERT", (int)Level::Alert}, |
|
1161
|
|
|
|
|
|
|
{"EMERGENCY", (int)Level::Emergency}, |
|
1162
|
|
|
|
|
|
|
}); |
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
auto root_module = xs::out(&::panda_log_module); |
|
1165
|
|
|
|
|
|
|
root_module.readonly(1); |
|
1166
|
|
|
|
|
|
|
stash.add_const_sub("default_format", xs::out(default_format)); |
|
1167
|
|
|
|
|
|
|
stash.add_const_sub("root", root_module); |
|
1168
|
|
|
|
|
|
|
stash.store("root_module", root_module); |
|
1169
|
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
xs::at_perl_destroy([]{ |
|
1171
|
|
|
|
|
|
|
if (dyn_cast(get_logger().get())) set_logger(nullptr); |
|
1172
|
|
|
|
|
|
|
if (dyn_cast(get_formatter().get())) set_formatter(nullptr); |
|
1173
|
|
|
|
|
|
|
}); |
|
1174
|
|
|
|
|
|
|
} |
|
1175
|
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
#line 4 "./xs/Logger.xsi" |
|
1177
|
|
|
|
|
|
|
{ |
|
1178
|
|
|
|
|
|
|
Stash("XLog::Logger").inherit("XLog::ILogger"); |
|
1179
|
|
|
|
|
|
|
} |
|
1180
|
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
#line 45 "./xs/Formatter.xsi" |
|
1182
|
|
|
|
|
|
|
{ |
|
1183
|
|
|
|
|
|
|
Stash("XLog::Formatter::Pattern").inherit("XLog::IFormatter"); |
|
1184
|
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
spy_$0_marker.svt_set = spy_$0; |
|
1186
|
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
auto $0_sv = get_sv("0", 0); |
|
1188
|
|
|
|
|
|
|
MAGIC* mg; |
|
1189
|
|
|
|
|
|
|
Newx(mg, 1, MAGIC); |
|
1190
|
|
|
|
|
|
|
mg->mg_moremagic = SvMAGIC($0_sv); |
|
1191
|
|
|
|
|
|
|
SvMAGIC_set($0_sv, mg); |
|
1192
|
|
|
|
|
|
|
mg->mg_virtual = const_cast(&spy_$0_marker); |
|
1193
|
|
|
|
|
|
|
mg->mg_type = PERL_MAGIC_ext; |
|
1194
|
|
|
|
|
|
|
mg->mg_len = 0; |
|
1195
|
|
|
|
|
|
|
mg->mg_private = 0; |
|
1196
|
|
|
|
|
|
|
mg->mg_flags = 0; |
|
1197
|
|
|
|
|
|
|
mg->mg_ptr = NULL; |
|
1198
|
|
|
|
|
|
|
mg->mg_obj = NULL; |
|
1199
|
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
auto $0 = SvPV_nolen($0_sv); |
|
1201
|
|
|
|
|
|
|
set_program_name(decorate_default($0)); |
|
1202
|
|
|
|
|
|
|
} |
|
1203
|
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
#line 27 "./xs/Console.xsi" |
|
1205
|
|
|
|
|
|
|
{ |
|
1206
|
|
|
|
|
|
|
Stash("XLog::Console").inherit("XLog::ILogger"); |
|
1207
|
|
|
|
|
|
|
} |
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
#line 27 "./xs/Multi.xsi" |
|
1210
|
|
|
|
|
|
|
{ |
|
1211
|
|
|
|
|
|
|
Stash("XLog::Multi").inherit("XLog::ILogger"); |
|
1212
|
|
|
|
|
|
|
} |
|
1213
|
|
|
|
|
|
|
|
|
1214
|
|
|
|
|
|
|
#line 1215 "XLog_xsgen.cc" |
|
1215
|
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
/* End of Initialisation Section */ |
|
1217
|
|
|
|
|
|
|
|
|
1218
|
|
|
|
|
|
|
#if PERL_VERSION_LE(5, 21, 5) |
|
1219
|
|
|
|
|
|
|
# if PERL_VERSION_GE(5, 9, 0) |
|
1220
|
|
|
|
|
|
|
if (PL_unitcheckav) |
|
1221
|
|
|
|
|
|
|
call_list(PL_scopestack_ix, PL_unitcheckav); |
|
1222
|
|
|
|
|
|
|
# endif |
|
1223
|
|
|
|
|
|
|
XSRETURN_YES; |
|
1224
|
|
|
|
|
|
|
#else |
|
1225
|
8
|
|
|
|
|
|
Perl_xs_boot_epilog(aTHX_ ax); |
|
1226
|
|
|
|
|
|
|
#endif |
|
1227
|
16
|
50
|
|
|
|
|
}); } |
|
1228
|
|
|
|
|
|
|
|