# IRCNOW lib
## Logger
example usage:
```perl
use strict;
use warnings;
use lib qw(./lib);
use Logger;
my $logger = new Logger(Logger->SUGAR, ":timestamp [:loglevel%5] :package%8 :fileline%10 :msg");
$logger->debug("debug");
$logger->info("info");
$logger->warn("warn");
$logger->error("error");
# output:
# 2023-07-02 19:22:03 [DEBUG] main test.pl:12 debug
# 2023-07-02 19:22:03 [INFO ] main test.pl:13 info
# 2023-07-02 19:22:03 [WARN ] main test.pl:14 warn
# 2023-07-02 19:22:03 [ERROR] main test.pl:15 error
```
### formating the logger
logger has these fields:
* timestamp
* loglevel
* package
* file
* fileline (file with line number)
* line
* msg
prepend the field with a `:` and postfix the field with a `%` followed by a number. Add spaces in between.
ex:
`:timestamp [:loglevel%5] :package%8 :fileline%10 :msg`
note: if your field value is longer than the specified length, it will print out the full value.
ex:
format: `:timestamp [:loglevel%2] :package%8 :fileline%10 :msg`
result:
```
2023-07-02 19:21:54 [DEBUG] main test.pl debug
2023-07-02 19:21:54 [INFO] main test.pl info
2023-07-02 19:21:54 [WARN] main test.pl warn
2023-07-02 19:21:54 [ERROR] main test.pl error
```