Branch Coverage

Logger.xs
Criterion Covered Total %
branch 115 162 70.9


line true false branch
29 67 0 if ( sv && SvPOK(sv) )
67 0 if ( sv && SvPOK(sv) )
30 67 0 path = SvPV_nolen( sv );
50 0 100 if ( level == LOG_DISABLE ) /* to move earlier */
54 63 37 if ( mylogger ) { /* we got a mylogger pointer */
55 63 0 if ( mylogger->filepath > 0 && strlen(mylogger->filepath) )
33 30 if ( mylogger->filepath > 0 && strlen(mylogger->filepath) )
60 50 13 if ( mylogger->pid && mylogger->pid != pid ) {
1 49 if ( mylogger->pid && mylogger->pid != pid ) {
61 1 0 if (mylogger->fhandle) fclose(mylogger->fhandle);
64 14 49 if ( ! mylogger->fhandle ) {
66 0 14 if ( (fhandle = fopen( path, "a" )) == NULL ) /* open in append mode */
70 14 0 ACQUIRE_LOCK_ONCE(fhandle); /* get a lock before moving to the end */
77 0 37 if ( (fhandle = fopen( path, "a" )) == NULL ) /* open in append mode */
79 37 0 ACQUIRE_LOCK_ONCE(fhandle); /* get a lock before moving to the end */
82 100 0 if ( fhandle ) {
85 58 42 if (num_args) va_start(args, num_args);
86 49 51 ACQUIRE_LOCK_ONCE(fhandle);
89 63 37 if ( mylogger && mylogger->use_color ) {
56 7 if ( mylogger && mylogger->use_color ) {
90 56 0 fprintf( fhandle, "[%s %s%02d%02d] %u %s%-5s%s: ",
99 44 0 fprintf( fhandle, "[%s %s%02d%02d] %u %-5s: ",
110 100 0 if ( fmt && (len=strlen(fmt)) ) {
58 42 if ( fmt && (len=strlen(fmt)) ) {
111 0 58 if (num_args == 0) /* no need to use sprintf when not needed */
117 58 42 if ( !len || fmt[len-1] != '\n')
57 1 if ( !len || fmt[len-1] != '\n')
120 63 37 if (has_logger_object) fflush(fhandle); /* otherwise we are going to close the ffhandle just after */
121 58 42 if (num_args) va_end(args);
123 100 0 RELEASE_LOCK(fhandle); /* only release if acquired before */
124 37 63 if ( !has_logger_object ) fclose( fhandle );
146 13 4 if( items > 1 ) { /* could also probably use va_start, va_list, ... */
148 13 0 if ( SvROK(extra) && SvTYPE(SvRV(extra)) == SVt_PVHV )
13 0 if ( SvROK(extra) && SvTYPE(SvRV(extra)) == SVt_PVHV )
153 13 4 if ( opts ) {
154 3 10 if ( (svp = hv_fetchs(opts, "color", FALSE)) ) {
155 0 3 if (!SvIOK(*svp)) croak("invalid color option value: should be a boolean 1/0");
156 3 0 mylogger->use_color = (bool) SvIV(*svp);
158 6 7 if ( (svp = hv_fetchs(opts, "level", FALSE)) ) {
159 0 6 if (!SvIOK(*svp)) croak("invalid log level: should be one integer");
160 6 0 mylogger->level = (logLevel) SvIV(*svp);
162 11 2 if ( (svp = hv_fetchs(opts, "logfile", FALSE)) || (svp = hv_fetchs(opts, "path", FALSE)) ) {
3 8 if ( (svp = hv_fetchs(opts, "logfile", FALSE)) || (svp = hv_fetchs(opts, "path", FALSE)) ) {
165 0 5 if (!SvPOK(*svp)) croak("invalid logfile path: must be a string");
166 5 0 src = SvPV(*svp, len);
167 0 5 if (len >= sizeof(mylogger->filepath))
224 100 15 if ( items && SvROK(ST(0)) && SvOBJECT(SvRV(ST(0))) ) { /* check if self is an object */
78 22 if ( items && SvROK(ST(0)) && SvOBJECT(SvRV(ST(0))) ) { /* check if self is an object */
78 0 if ( items && SvROK(ST(0)) && SvOBJECT(SvRV(ST(0))) ) { /* check if self is an object */
227 78 0 mylogger = INT2PTR(MyLogger*, SvIV(SvRV(self)));
229 10 68 if ( level < mylogger->level )
232 105 10 if (dolog) {
234 42 63 if ( items < (1 + args_start_at) ) { /* */
238 58 5 } else if ( items <= ( 11 + args_start_at ) ) { /* set a cap on the maximum of item we can use: 10 arguments + 1 format + 1 for self */
244 125 58 for ( i = args_start_at ; i < items ; ++i ) {
246 0 125 if ( !SvOK(sv) )
0 0 if ( !SvOK(sv) )
0 0 if ( !SvOK(sv) )
250 58 67 if ( i == args_start_at ) { /* the first entry shoulkd be the format */
251 1 57 if ( !SvPOK(sv) ) { /* maybe upgrade to a PV */
252 1 0 if ( SvIOK(sv) )
253 1 0 SvUPGRADE(sv, SVt_PVIV);
257 57 1 fmt = SvPV_nolen( sv );
260 61 6 if ( SvIOK(sv) ) { /* SvTYPE(sv) == SVt_IV */
261 61 0 targs[ix].ival = SvIV(sv);
262 1 5 } else if ( SvNOK(sv) ) { // not working for now
265 1 0 targs[ix].fval = SvNV(sv);
267 5 0 targs[ix].sval = SvPV_nolen(sv);
338 24 86 if ( should_die ) /* maybe fatal needs to exit */
355 6 0 mylogger = INT2PTR(MyLogger*, SvIV(SvRV(self)));
383 1 0 mylogger = INT2PTR(MyLogger*, SvIV(SvRV(self)));
384 1 0 switch (ix) {
386 0 1 if ( !SvIOK(value) ) croak("invalid level: must be interger.");
387 1 0 mylogger->level = SvIV(value);
403 17 0 if ( self && SvROK(self) && SvOBJECT(SvRV(self)) ) { /* check if self is an object */
17 0 if ( self && SvROK(self) && SvOBJECT(SvRV(self)) ) { /* check if self is an object */
17 0 if ( self && SvROK(self) && SvOBJECT(SvRV(self)) ) { /* check if self is an object */
404 17 0 mylogger = INT2PTR(MyLogger*, SvIV(SvRV(self)));
406 13 4 if ( mylogger->fhandle )
411 17 0 if (PL_markstack_ptr != temp) {
433 7 1 if ( ! SvPOK(sv) ) { /* preserve any value set before loading the module */