A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

How to disable Mojo debug logging

When setting MOJO_LOG_LEVEL does not work... Make the following hacks:

removing debug output

~ ============================================================================ Tuesday 12th February 2019

~~~ FIXES FOR OLD VERSION OF MOJO (Supervillain 8.03)

../local/lib/perl5/Mojolicious.pm
132:    $self->log->debug(qq{$method "$path" ($id)}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Controller.pm
209:      $app->log->debug("$code $msg (${elapsed}s, $rps/s)") if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Plugin/EPLRenderer.pm
18:    $c->app->log->debug("Rendering cached @{[$mt->name]}") if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
30:      $c->app->log->debug(qq{Rendering inline template "$name"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
40:        $c->app->log->debug(qq{Rendering template "$name"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
46:        $c->app->log->debug(qq{Rendering template "$name" from DATA section}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Routes.pm
95:  $app->log->debug('Routing to a callback') if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
150:    $log->debug(qq{Routing to application "$class"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
164:      $log->debug(qq{Routing to controller "$class" and action "$method"}) if $ENV{MOJO_DEBUG} || $ENV{BB_DEBUG};

~ ============================================================================ Thursday 7th March 2019

local/lib/perl5/Mojolicious.pm
123:          #return unless $ENV{MOJO_DEBUG}; # WS hack

local/lib/perl5/Mojolicious/Controller.pm
187:      return unless $ENV{MOJO_DEBUG};

local/lib/perl5/Mojolicious/Routes.pm
103:  $app->log->debug('Routing to a callback') if $ENV{MOJO_DEBUG};
170:      $log->debug(qq{Routing to controller "$class" and action "$method"}) if $ENV{MOJO_DEBUG};

x
491:>> /Users/will/dev/ats-broadcast-hub/local/lib/perl5/Mojolicious/Routes.pm:103:   $app->log->debug('Routing to a callback') if $ENV{MOJO_DEBUG};

~~~~ AND ~~~~

To fix CODE(0x7fde03335ca0) now:

vi local/lib/perl5/Mojolicious.pm +122

~~~ OLD VERSION OF MOJO

local/lib/perl5/Mojolicious.pm

  60 our $CODENAME = 'Supervillain';
  61 our $VERSION  = '8.03';

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121   unless ($stash->{'mojo.static'} || $stash->{'mojo.started'}) {
 122     my $req    = $c->req;
 123     my $method = $req->method;
 124     my $path   = $req->url->path->to_abs_string;
 125     my $id     = $req->request_id;
 126     $self->log->debug(qq{$method "$path" ($id)});
 127     $c->helpers->timing->begin('mojo.timer');
 128   }

~~~ NEW VERSION OF MOJO

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121   $self->log->debug(sub {
 122     my $req    = $c->req;
 123     my $method = $req->method;
 124     my $path   = $req->url->path->to_abs_string;
 125     my $id     = $req->request_id;
 126     $c->helpers->timing->begin('mojo.timer');
 127     return qq{$method "$path" ($id)};
 128   }) unless $stash->{'mojo.static'};
 129 

~~~ FIX FOR NEW VERSION (8.12)

vi local/lib/perl5/Mojolicious.pm

  61 our $CODENAME = 'Supervillain';
  62 our $VERSION  = '8.12';

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121     my $req    = $c->req;
 122     my $method = $req->method;
 123     my $path   = $req->url->path->to_abs_string;
 124     my $id     = $req->request_id;
 125     $c->helpers->timing->begin('mojo.timer');
 126 if ($ENV{MOJO_DEBUG}) {
 127     $self->log->debug(qq{$method "$path" ($id)}) unless $stash->{'mojo.static'};
 128 }

vi local/lib/perl5/Mojolicious/Controller.pm

184     # Disable auto rendering and stop timer
185     my $app = $self->render_later->app;
186 #    $app->log->debug(sub {
187       my $timing  = $self->helpers->timing;
188       my $elapsed = $timing->elapsed('mojo.timer') // 0;
189       my $rps     = $timing->rps($elapsed) // '??';
190       my $code    = $res->code;
191       my $msg     = $res->message || $res->default_message($code);
192 #      return "$code $msg (${elapsed}s, $rps/s)";
193 #    }) unless $stash->{'mojo.static'};
194 if ($ENV{MOJO_DEBUG}) {
195       $app->log->debug("$code $msg (${elapsed}s, $rps/s)") unless $stash->{'mojo.static'}; # MOJO_DEBUG
196 }