commit a87809859709dc100c7e9ae2d2dcb6fc7dc14bb1 from: TheLion date: Thu Jul 06 01:02:50 2023 UTC fix: add backwards compatible verbosity levels commit - 8851c7ffe6b88fb9a279460c29eb5fb15e19dc60 commit + a87809859709dc100c7e9ae2d2dcb6fc7dc14bb1 blob - 8e8e0d50c41593c90f5426ed0917d82a4cdac206 blob + d06136eca335d1956a11fc6d4481d1f842dffad0 --- README.md +++ README.md @@ -1,8 +1,13 @@ # IRCNOW lib +* 1. [Logger](#Logger) + * 1.1. [Formating the logger](#Formatingthelogger) + * 1.2. [SUGAR vs JSON](#SUGARvsJSON) + * 1.3. [Loggin Verbosity](#LogginVerbosity) -## Logger +## 1. Logger + Example usage: ```perl use strict; @@ -32,7 +37,7 @@ $logger->error("error"); Arguments are: `verbosity, printType, format`. -### Formating the logger +### 1.1. Formating the logger Logger has these fields: * timestamp @@ -59,7 +64,7 @@ result: 2023-07-02 19:21:54 [ERROR] main test.pl error ``` -### SUGAR vs JSON +### 1.2. SUGAR vs JSON There are two options to print logs: * sugar @@ -84,3 +89,16 @@ Example of Sugar: 2023-07-02 19:22:03 [ERROR] main test.pl:15 error ``` +### 1.3. Logging Verbosity + +There are verbosity levels: +* NONE +* ERRORS +* ERROR (backwards compatible) +* WARNINGS +* WARN (backwards compatible) +* INFO +* DEBUG +* ALL + +Each level is in order such that if the `INFO` level was chosen, you would see logs for `ERROR`, `WARN`, and `INFO` blob - f13ea4b61dbeea6682d0eab7b9aaecea3670291b blob + 10c0ad62df7491a3a20b149706b9598991bf806c --- lib/IRCNOW/Logger.pm +++ lib/IRCNOW/Logger.pm @@ -14,12 +14,14 @@ my $blue = "\033[94m"; my $magenta = "\033[35m"; my $cyan = "\033[36m"; -our @EXPORT_OK = qw(debug info warn error NONE ERRORS WARNINGS INFO DEBUG ALL JSON SUGAR); +our @EXPORT_OK = qw(debug info warn error NONE ERRORS ERROR WARNINGS WARN INFO DEBUG ALL JSON SUGAR); use constant { NONE => 0, ERRORS => 1, + ERROR => 1, WARNINGS => 2, + WARN => 2, INFO => 3, DEBUG => 4, ALL => 5, @@ -40,9 +42,9 @@ sub logMessage { if ($level == NONE) { $levelString = "NONE"; - } elsif ($level == ERRORS) { + } elsif ($level == ERROR) { $levelString = "ERROR"; - } elsif ($level == WARNINGS) { + } elsif ($level == WARN) { $levelString = "WARN"; } elsif ($level == INFO) { $levelString = "INFO";