Branch Coverage

XLog_xsgen.cc
Criterion Covered Total %
branch 253 624 40.5


line true false branch
169 1 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl formatting callback: log() called from perl-foreign thread");
0 1 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl formatting callback: log() called from perl-foreign thread");
0 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl formatting callback: log() called from perl-foreign thread");
170 1 0 Object o = xs::out(this);
1 0 Object o = xs::out(this);
171 1 0 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));
1 0 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));
1 0 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));
1 0 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));
1 0 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));
1 0 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));
1 0 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));
1 0 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));
172 1 0 return xs::in(ret);
175 0 1 ~PerlObjectFormatter () { Backref::dtor(); }
179 122 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
0 122 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
0 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
180 122 0 Object o = xs::out(this);
122 0 Object o = xs::out(this);
181 122 0 auto sub = o.method("log_format");
121 1 auto sub = o.method("log_format");
182 1 121 if (!sub) return ILogger::log_format(msg, i, fmt);
1 0 if (!sub) return ILogger::log_format(msg, i, fmt);
183 121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 0 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));
121 1 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));
187 1 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
0 1 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
0 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
188 1 0 Object o = xs::out(this);
1 0 Object o = xs::out(this);
189 1 0 o.call("log", xs::out(msg), xs::out(info.level));
1 0 o.call("log", xs::out(msg), xs::out(info.level));
1 0 o.call("log", xs::out(msg), xs::out(info.level));
192 0 24 ~PerlObjectLogger () { Backref::dtor(); }
202 137 0 auto ctx = caller_cx(depth, nullptr);
203 137 1 while (ctx) {
204 136 1 if (CxTYPE(ctx) == CXt_SUB) return ctx->blk_sub.cv;
205 1 0 ctx = caller_cx(++depth, nullptr);
213 137 0 auto cv = get_context_sub();
214 136 1 if (cv) {
215 136 0 GV* gv = CvGV(cv);
216 136 0 if (gv) func = string_view(GvNAME(gv), GvNAMELEN(gv));
219 137 0 return CodePoint{CopFILE(cop), CopLINE(cop), func};
222 25 112 if (!items) return Simple(default_message);
25 0 if (!items) return Simple(default_message);
223 108 4 if (items == 1) {
225 104 4 if (arg.is_simple()) { return arg; }
226 0 4 else { return Simple(SvPV_nolen(args[0])); }
4 0 else { return Simple(SvPV_nolen(args[0])); }
4 0 else { return Simple(SvPV_nolen(args[0])); }
229 4 0 auto pat = SvPV(args[0], patlen);
0 0 auto pat = SvPV(args[0], patlen);
230 4 0 auto ret = Simple::create(patlen * 1.5);
232 4 0 sv_vcatpvfn(ret, pat, patlen, nullptr, args + 1, items - 1, &stub);
233 4 0 return ret;
236 140 25 if (items && SvROK(args[0])) {
55 85 if (items && SvROK(args[0])) {
238 55 0 if (has_module(first)) {
48 7 if (has_module(first)) {
239 48 0 module = xs::in(first);
243 5 2 else if (SvTYPE(first) == SVt_PVCV) {
244 0 5 if (items > 1) throw exception("no arguments should follow subref when logging");
245 5 0 sub = first;
249 117 48 if (!module) module = resolve_module(0); // auto detect module by namespace
254 5 132 if (sub) {
255 5 0 Sv ret = sub.call();
257 5 0 msg = format_args(&sv, 1);
5 0 msg = format_args(&sv, 1);
260 132 0 msg = format_args(args, items);
132 0 msg = format_args(args, items);
262 137 0 log << msg.as_string();
137 0 log << msg.as_string();
267 165 0 peep_args(args, items, module, sub);
268 165 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 28 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
137 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
275 30 0 if (items < 1 || items > 2)
0 30 if (items < 1 || items > 2)
280 30 0 Level level = xs::in(ST(0));
284 30 0 if (items < 2)
288 0 0 const char* __module_buf = SvPV(ST(1), __module_len);
0 0 const char* __module_buf = SvPV(ST(1), __module_len);
298 30 0 }); }
305 0 53 if (items != 1)
310 53 0 ILoggerSP logger = xs::in(ST(0));
318 53 0 }); }
326 0 50 if (items != 1)
331 50 0 IFormatterSP fmt = xs::in(ST(0));
340 50 0 }); }
347 0 1 if (items != 0)
357 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
358 1 0 RETVALSV = sv_2mortal(RETVALSV);
363 1 0 }); }
370 0 1 if (items != 0)
380 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
381 1 0 RETVALSV = sv_2mortal(RETVALSV);
386 1 0 }); }
393 0 3 if (items != 1)
400 3 0 const char* __name_buf = SvPV(ST(0), __name_len);
0 0 const char* __name_buf = SvPV(ST(0), __name_len);
409 3 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
410 3 0 RETVALSV = sv_2mortal(RETVALSV);
415 3 0 }); }
422 0 64 if (items < 1)
436 64 0 }); }
443 20 0 if (items < 0 || items > 1)
0 20 if (items < 0 || items > 1)
449 0 20 if (items < 1)
453 0 20 ;
20 0 ;
461 20 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
462 20 0 RETVALSV = sv_2mortal(RETVALSV);
467 20 0 }); }
487 101 0 }); }
500 0 24 if (items != 1)
514 24 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
515 24 0 RETVALSV = sv_2mortal(RETVALSV);
520 24 0 }); }
533 0 1 if (items != 1)
547 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
548 1 0 RETVALSV = sv_2mortal(RETVALSV);
553 1 0 }); }
559 8 0 auto pos = in.find_last_of("/\\");
560 0 8 if (pos == string::npos) {
561 0 0 return in;
563 8 0 return in.substr(pos + 1);
567 1 0 if (mg->mg_virtual == &spy_$0_marker) {
568 1 0 Stash stash("XLog::Formatter::Pattern");
569 1 0 auto decorator = stash.sub(DECORATOR_KEY);
571 1 0 if (decorator) {
572 1 0 auto decorated = decorator.call(sv);
573 1 0 $0 = SvPV_nolen(decorated);
0 0 $0 = SvPV_nolen(decorated);
1 0 $0 = SvPV_nolen(decorated);
576 0 0 $0 = decorate_default(SvPV_nolen(sv));
0 0 $0 = decorate_default(SvPV_nolen(sv));
0 0 $0 = decorate_default(SvPV_nolen(sv));
0 0 $0 = decorate_default(SvPV_nolen(sv));
587 0 1 if (items != 2)
596 1 0 const char* __fmt_buf = SvPV(ST(1), __fmt_len);
0 0 const char* __fmt_buf = SvPV(ST(1), __fmt_len);
606 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
607 1 0 RETVALSV = sv_2mortal(RETVALSV);
612 1 0 }); }
619 0 1 if (items != 1)
624 1 0 Sub callback = ST(0);
625 0 1 if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
0 0 if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
0 0 if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
0 0 if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
0 1 if (!callback && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
634 1 0 }); }
647 24 0 if (items < 2 || items > 4)
0 24 if (items < 2 || items > 4)
653 24 0 string name;
654 24 0 Sv arg1;
655 24 0 Sv arg2;
658 24 0 const char* __name_buf = SvPV(ST(1), __name_len);
0 0 const char* __name_buf = SvPV(ST(1), __name_len);
659 24 0 name.assign(__name_buf, __name_len); }
662 8 16 if (items < 3)
666 16 0 ;
669 23 1 if (items < 4)
673 1 0 ;
704 0 24 if (!RETVAL) XSRETURN_UNDEF;
705 24 0 if (RETVAL.is_scalar()) RETVALSV = RETVAL.detach();
24 0 if (RETVAL.is_scalar()) RETVALSV = RETVAL.detach();
707 0 0 case SVt_PVAV: XSRETURN(xs::Array(RETVAL.get()).push_on_stack(MARK));
0 0 case SVt_PVAV: XSRETURN(xs::Array(RETVAL.get()).push_on_stack(MARK));
708 0 0 case SVt_PVHV: XSRETURN(xs::Hash(RETVAL.get()).push_on_stack(MARK));
0 0 case SVt_PVHV: XSRETURN(xs::Hash(RETVAL.get()).push_on_stack(MARK));
711 0 0 RETVALSV = newRV_noinc(RETVAL.detach());
715 24 0 RETVALSV = sv_2mortal(RETVALSV);
716 24 0 ST(0) = RETVALSV;
720 24 0 }); }
727 0 4 if (items != 1)
731 4 0 dXSTARG;
0 0 dXSTARG;
732 4 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 4 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
737 4 0 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
0 4 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
0 0 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
740 4 0 }); }
747 0 5 if (items != 1)
751 5 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 5 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
759 5 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
760 5 0 RETVALSV = sv_2mortal(RETVALSV);
765 5 0 }); }
772 0 0 if (items != 1)
776 0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
781 0 0 ST(0) = boolSV(RETVAL);
784 0 0 }); }
791 0 2 if (items != 2)
796 0 2 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
806 2 0 }); }
813 4 0 if (items < 2 || items > 3)
0 4 if (items < 2 || items > 3)
818 4 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 4 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
820 4 0 ILoggerSP logger = xs::in(ST(1));
824 3 1 if (items < 3)
827 1 0 passthrough = (bool)SvTRUE(ST(2))
0 1 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 1 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
1 0 passthrough = (bool)SvTRUE(ST(2))
1 0 passthrough = (bool)SvTRUE(ST(2))
0 1 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
0 0 passthrough = (bool)SvTRUE(ST(2))
836 4 0 }); }
843 0 2 if (items != 2)
848 2 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 2 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
850 2 0 IFormatterSP formatter = xs::in(ST(1));
858 2 0 }); }
865 0 0 if (items != 1)
869 0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
877 0 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
878 0 0 RETVALSV = sv_2mortal(RETVALSV);
883 0 0 }); }
890 0 0 if (items != 1)
894 0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
0 0 Module* THIS = xs::in(ST(0)); if (!SvOK(ST(0))) throw "undef not allowed as THIS";
902 0 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
903 0 0 RETVALSV = sv_2mortal(RETVALSV);
908 0 0 }); }
917 0 0 struct XSConsoleLogger : ConsoleLogger {
921 1 0 Io io = PL_defoutgv;
922 0 1 if (!io) return;
924 0 1 if (!fp) return;
925 1 0 PerlIO_write(fp, msg.data(), msg.length());
926 1 0 PerlIO_write(fp, "\n", 1);
1 0 PerlIO_write(fp, "\n", 1);
940 0 1 if (items != 1)
953 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
954 1 0 RETVALSV = sv_2mortal(RETVALSV);
959 1 0 }); }
971 8 0 auto ret = MultiLogger::Channel(xs::in(h.fetch("logger")));
8 0 auto ret = MultiLogger::Channel(xs::in(h.fetch("logger")));
8 0 auto ret = MultiLogger::Channel(xs::in(h.fetch("logger")));
8 0 auto ret = MultiLogger::Channel(xs::in(h.fetch("logger")));
973 8 0 if ((val = h.fetch("min_level"))) ret.min_level = xs::in(val);
8 0 if ((val = h.fetch("min_level"))) ret.min_level = xs::in(val);
8 0 if ((val = h.fetch("min_level"))) ret.min_level = xs::in(val);
974 8 0 if ((val = h.fetch("formatter"))) ret.formatter = xs::in(val);
4 4 if ((val = h.fetch("formatter"))) ret.formatter = xs::in(val);
4 0 if ((val = h.fetch("formatter"))) ret.formatter = xs::in(val);
975 8 0 if ((val = h.fetch("format")) && val.defined()) {
0 8 if ((val = h.fetch("format")) && val.defined()) {
0 0 if ((val = h.fetch("format")) && val.defined()) {
8 0 if ((val = h.fetch("format")) && val.defined()) {
8 0 if ((val = h.fetch("format")) && val.defined()) {
0 8 if ((val = h.fetch("format")) && val.defined()) {
0 0 if ((val = h.fetch("format")) && val.defined()) {
0 0 if ((val = h.fetch("format")) && val.defined()) {
976 0 0 auto fmt = xs::in(val);
977 0 0 if (fmt.length()) ret.formatter = new PatternFormatter(fmt);
0 0 if (fmt.length()) ret.formatter = new PatternFormatter(fmt);
0 0 if (fmt.length()) ret.formatter = new PatternFormatter(fmt);
992 0 2 if (items != 2)
998 2 0 MultiLogger::Channels list = xs::in(ST(1));
1007 2 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
1008 2 0 RETVALSV = sv_2mortal(RETVALSV);
1013 2 0 }); }
1027 0 8 dVAR; dXSBOOTARGSXSAPIVERCHK;
0 8 dVAR; dXSBOOTARGSXSAPIVERCHK;
1174 8 0 }); }