Branch Coverage

XLog_xsgen.cc
Criterion Covered Total %
branch 258 630 40.9


line true false branch
172 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");
173 1 0 Object o = xs::out(this);
1 0 Object o = xs::out(this);
174 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));
175 1 0 return xs::in(ret);
178 0 1 ~PerlObjectFormatter () { Backref::dtor(); }
183 123 0 if (!is_perl_thread()) throw std::logic_error("can't call pure-perl logging callback: log() called from perl-foreign thread");
0 123 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");
184 123 0 Object o = xs::out(this);
123 0 Object o = xs::out(this);
185 123 0 auto sub = o.method("log_format");
122 1 auto sub = o.method("log_format");
186 1 122 if (!sub) return ILogger::log_format(msg, i, fmt);
1 0 if (!sub) return ILogger::log_format(msg, i, fmt);
187 122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
122 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));
191 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");
192 1 0 Object o = xs::out(this);
1 0 Object o = xs::out(this);
193 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));
196 0 25 ~PerlObjectLogger () { Backref::dtor(); }
201 6 1 if (!_enabled) return;
209 4 1 if (!_enabled) return;
228 138 0 auto ctx = caller_cx(depth, nullptr);
229 138 1 while (ctx) {
230 137 1 if (CxTYPE(ctx) == CXt_SUB) return ctx->blk_sub.cv;
231 1 0 ctx = caller_cx(++depth, nullptr);
239 138 0 auto cv = get_context_sub();
240 137 1 if (cv) {
241 137 0 GV* gv = CvGV(cv);
242 137 0 if (gv) func = string_view(GvNAME(gv), GvNAMELEN(gv));
245 138 0 return CodePoint{CopFILE(cop), CopLINE(cop), func};
248 25 115 if (!items) return Simple(default_message);
25 0 if (!items) return Simple(default_message);
250 108 7 if (items == 1) {
252 104 4 if (arg.is_simple()) { return arg; }
253 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])); }
259 7 0 auto pat = SvPV(args[0], patlen);
0 0 auto pat = SvPV(args[0], patlen);
260 7 0 Sv ret = Simple::create(patlen * 1.5);
262 5 0 sv_vcatpvfn(ret, pat, patlen, nullptr, args + 1, items - 1, &stub);
266 143 25 if (items && SvROK(args[0])) {
55 88 if (items && SvROK(args[0])) {
268 55 0 if (has_module(first)) {
48 7 if (has_module(first)) {
269 48 0 module = xs::in(first);
273 5 2 else if (SvTYPE(first) == SVt_PVCV) {
274 0 5 if (items > 1) throw exception("no arguments should follow subref when logging");
275 5 0 sub = first;
279 120 48 if (!module) module = resolve_module(0); // auto detect module by namespace
284 5 135 if (sub) {
285 5 0 Sv ret = sub.call();
287 5 0 msg = format_args(&sv, 1);
5 0 msg = format_args(&sv, 1);
290 133 0 msg = format_args(args, items);
133 0 msg = format_args(args, items);
292 138 0 log << msg.as_string();
138 0 log << msg.as_string();
297 168 0 peep_args(args, items, module, sub);
298 168 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
140 28 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
140 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
138 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
138 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
138 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
138 0 panda_log(level, *module, [&]{ forward(log, args, items, sub); });
305 31 0 if (items < 1 || items > 2)
0 31 if (items < 1 || items > 2)
310 31 0 Level level = xs::in(ST(0));
314 31 0 if (items < 2)
318 0 0 const char* __module_buf = SvPV(ST(1), __module_len);
0 0 const char* __module_buf = SvPV(ST(1), __module_len);
328 31 0 }); }
335 0 55 if (items != 1)
340 55 0 ILoggerSP logger = xs::in(ST(0));
348 55 0 }); }
356 0 52 if (items != 1)
361 52 0 IFormatterSP fmt = xs::in(ST(0));
370 52 0 }); }
377 0 1 if (items != 0)
387 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
388 1 0 RETVALSV = sv_2mortal(RETVALSV);
393 1 0 }); }
400 0 1 if (items != 0)
410 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
411 1 0 RETVALSV = sv_2mortal(RETVALSV);
416 1 0 }); }
423 0 3 if (items != 1)
430 3 0 const char* __name_buf = SvPV(ST(0), __name_len);
0 0 const char* __name_buf = SvPV(ST(0), __name_len);
439 3 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
440 3 0 RETVALSV = sv_2mortal(RETVALSV);
445 3 0 }); }
452 0 64 if (items < 1)
466 64 0 }); }
473 20 0 if (items < 0 || items > 1)
0 20 if (items < 0 || items > 1)
479 0 20 if (items < 1)
483 0 20 ;
20 0 ;
491 20 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
492 20 0 RETVALSV = sv_2mortal(RETVALSV);
497 20 0 }); }
505 0 2 if (items != 0)
516 2 0 }); }
536 102 0 }); }
549 0 25 if (items != 1)
563 25 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
564 25 0 RETVALSV = sv_2mortal(RETVALSV);
569 25 0 }); }
582 0 1 if (items != 1)
596 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
597 1 0 RETVALSV = sv_2mortal(RETVALSV);
602 1 0 }); }
608 8 0 auto pos = in.find_last_of("/\\");
609 0 8 if (pos == string::npos) {
610 0 0 return in;
612 8 0 return in.substr(pos + 1);
616 1 0 if (mg->mg_virtual == &spy_$0_marker) {
617 1 0 Stash stash("XLog::Formatter::Pattern");
618 1 0 auto decorator = stash.sub(DECORATOR_KEY);
620 1 0 if (decorator) {
621 1 0 auto decorated = decorator.call(sv);
622 1 0 $0 = SvPV_nolen(decorated);
0 0 $0 = SvPV_nolen(decorated);
1 0 $0 = SvPV_nolen(decorated);
625 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));
636 0 1 if (items != 2)
645 1 0 const char* __fmt_buf = SvPV(ST(1), __fmt_len);
0 0 const char* __fmt_buf = SvPV(ST(1), __fmt_len);
655 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
656 1 0 RETVALSV = sv_2mortal(RETVALSV);
661 1 0 }); }
668 0 1 if (items != 1)
673 1 0 Sub callback = ST(0);
674 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"
683 1 0 }); }
696 24 0 if (items < 2 || items > 4)
0 24 if (items < 2 || items > 4)
702 24 0 string name;
703 24 0 Sv arg1;
704 24 0 Sv arg2;
707 24 0 const char* __name_buf = SvPV(ST(1), __name_len);
0 0 const char* __name_buf = SvPV(ST(1), __name_len);
708 24 0 name.assign(__name_buf, __name_len); }
711 8 16 if (items < 3)
715 16 0 ;
718 23 1 if (items < 4)
722 1 0 ;
753 0 24 if (!RETVAL) XSRETURN_UNDEF;
754 24 0 if (RETVAL.is_scalar()) RETVALSV = RETVAL.detach();
24 0 if (RETVAL.is_scalar()) RETVALSV = RETVAL.detach();
756 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));
757 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));
760 0 0 RETVALSV = newRV_noinc(RETVAL.detach());
764 24 0 RETVALSV = sv_2mortal(RETVALSV);
765 24 0 ST(0) = RETVALSV;
769 24 0 }); }
776 0 4 if (items != 1)
780 4 0 dXSTARG;
0 0 dXSTARG;
781 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";
786 4 0 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
0 4 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
0 0 XSprePUSH; PUSHp(RETVAL.data(), RETVAL.length());
789 4 0 }); }
796 0 5 if (items != 1)
800 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";
808 5 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
809 5 0 RETVALSV = sv_2mortal(RETVALSV);
814 5 0 }); }
821 0 0 if (items != 1)
825 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";
830 0 0 ST(0) = boolSV(RETVAL);
833 0 0 }); }
840 0 2 if (items != 2)
845 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";
855 2 0 }); }
862 4 0 if (items < 2 || items > 3)
0 4 if (items < 2 || items > 3)
867 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";
869 4 0 ILoggerSP logger = xs::in(ST(1));
873 3 1 if (items < 3)
876 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))
885 4 0 }); }
892 0 2 if (items != 2)
897 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";
899 2 0 IFormatterSP formatter = xs::in(ST(1));
907 2 0 }); }
914 0 0 if (items != 1)
918 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";
926 0 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
927 0 0 RETVALSV = sv_2mortal(RETVALSV);
932 0 0 }); }
939 0 0 if (items != 1)
943 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";
951 0 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
952 0 0 RETVALSV = sv_2mortal(RETVALSV);
957 0 0 }); }
966 0 0 struct XSConsoleLogger : ConsoleLogger {
970 1 0 Io io = PL_defoutgv;
971 0 1 if (!io) return;
973 0 1 if (!fp) return;
974 1 0 PerlIO_write(fp, msg.data(), msg.length());
975 1 0 PerlIO_write(fp, "\n", 1);
1 0 PerlIO_write(fp, "\n", 1);
989 0 1 if (items != 1)
1002 1 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
1003 1 0 RETVALSV = sv_2mortal(RETVALSV);
1008 1 0 }); }
1020 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")));
1022 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);
1023 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);
1024 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()) {
1025 0 0 auto fmt = xs::in(val);
1026 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);
1041 0 2 if (items != 2)
1047 2 0 MultiLogger::Channels list = xs::in(ST(1));
1056 2 0 RETVALSV = xs::out(RETVAL, PROTO).detach();
1057 2 0 RETVALSV = sv_2mortal(RETVALSV);
1062 2 0 }); }
1076 0 8 dVAR; dXSBOOTARGSXSAPIVERCHK;
0 8 dVAR; dXSBOOTARGSXSAPIVERCHK;
1227 8 0 }); }