Skip to content

Commit

Permalink
increase the performance gain to 60% for lower log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 8, 2018
1 parent 11625c0 commit be201fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Mojo/Log.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ sub append {
flock $handle, LOCK_UN;
}

sub debug { $_[0]->is_level('debug') ? _log(@_, 'debug') : $_[0] }
sub error { $_[0]->is_level('error') ? _log(@_, 'error') : $_[0] }
sub fatal { $_[0]->is_level('fatal') ? _log(@_, 'fatal') : $_[0] }
sub info { $_[0]->is_level('info') ? _log(@_, 'info') : $_[0] }
sub debug { 1 >= $LEVEL{$_[0]->level} ? _log(@_, 'debug') : $_[0] }
sub error { 4 >= $LEVEL{$_[0]->level} ? _log(@_, 'error') : $_[0] }
sub fatal { 5 >= $LEVEL{$_[0]->level} ? _log(@_, 'fatal') : $_[0] }
sub info { 2 >= $LEVEL{$_[0]->level} ? _log(@_, 'info') : $_[0] }

sub is_level { $LEVEL{pop()} >= $LEVEL{shift->level} }

Expand All @@ -50,7 +50,7 @@ sub new {
return $self;
}

sub warn { $_[0]->is_level('warn') ? _log(@_, 'warn') : $_[0] }
sub warn { 3 >= $LEVEL{$_[0]->level} ? _log(@_, 'warn') : $_[0] }

sub _default {
my ($time, $level) = (shift, shift);
Expand Down

0 comments on commit be201fa

Please sign in to comment.