commit 2e32cc1047d607473b413e431194b499a81a0de7 from: TheLion date: Thu Jul 06 01:02:51 2023 UTC refactor: rename instance to self commit - a87809859709dc100c7e9ae2d2dcb6fc7dc14bb1 commit + 2e32cc1047d607473b413e431194b499a81a0de7 blob - 10c0ad62df7491a3a20b149706b9598991bf806c blob + 02b774d3e642f8c2644c5d7ef273609a614361eb --- lib/IRCNOW/Logger.pm +++ lib/IRCNOW/Logger.pm @@ -33,10 +33,10 @@ use constant { }; -my $instance = undef; +my $self = undef; sub logMessage { - my ($instance, $level, $package, $filename, $line, $msg) = @_; + my ($self, $level, $package, $filename, $line, $msg) = @_; my $levelString; @@ -54,16 +54,16 @@ sub logMessage { $levelString = "ALL"; } - if (int($instance->{'verbosity'}) >= $level) { $instance->printLog($level, $levelString, $package, $filename, $line, $msg); } + if (int($self->{'verbosity'}) >= $level) { $instance->printLog($level, $levelString, $package, $filename, $line, $msg); } } sub printLog { - my ($instance, $level, $levelString, $package, $filename, $line, $msg) = @_; + my ($self, $level, $levelString, $package, $filename, $line, $msg) = @_; - if ($instance->{'printType'} == JSON) { + if ($self->{'printType'} == JSON) { printJSON($level, $levelString, $package, $filename, $line, $msg); - } elsif ($instance->{'printType'} == SUGAR) { - printSugar($instance->{'format'}, $level, $levelString, $package, $filename, $line, $msg); + } elsif ($self->{'printType'} == SUGAR) { + printSugar($self->{'format'}, $level, $levelString, $package, $filename, $line, $msg); } } @@ -84,35 +84,35 @@ sub printSugar { } sub debug { - my ($instance, $msg) = @_; + my ($self, $msg) = @_; my ($package, $filename, $line) = caller; - $instance->logMessage(DEBUG, $package, $filename, $line, $msg); + $self->logMessage(DEBUG, $package, $filename, $line, $msg); } sub warn { - my ($instance, $msg) = @_; + my ($self, $msg) = @_; my ($package, $filename, $line) = caller; - $instance->logMessage(WARNINGS, $package, $filename, $line, $msg); + $self->logMessage(WARNINGS, $package, $filename, $line, $msg); } sub info { - my ($instance, $msg) = @_; + my ($self, $msg) = @_; my ($package, $filename, $line) = caller; - $instance->logMessage(INFO, $package, $filename, $line, $msg); + $self->logMessage(INFO, $package, $filename, $line, $msg); } sub error { - my ($instance, $msg) = @_; + my ($self, $msg) = @_; my ($package, $filename, $line) = caller; - $instance->logMessage(ERRORS, $package, $filename, $line, $msg); + $self->logMessage(ERRORS, $package, $filename, $line, $msg); } sub formatLog { @@ -200,7 +200,7 @@ sub getDataValue { sub new { my $class = shift; - $instance ||= bless { + $self ||= bless { 'verbosity' => DEBUG, 'printType' => JSON, 'format' => ":timestamp [:loglevel%5] :package%8 :fileline%10 :msg", @@ -213,16 +213,16 @@ sub new { my $passedFormat = shift; if (defined $passedVerbosity) { - $instance->{'verbosity'} = $passedVerbosity; + $self->{'verbosity'} = $passedVerbosity; } if (defined $passedPrintType) { - $instance->{'printType'} = $passedPrintType; + $self->{'printType'} = $passedPrintType; } if (defined $passedFormat) { - $instance->{'format'} = $passedFormat; + $self->{'format'} = $passedFormat; } - return $instance; + return $self; }