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