Log::JSON::Lines - Log in JSONLines format
Version 1.00
Quick summary of what the module does.
use Log::JSON::Lines; my $logger = Log::JSON::Lines->new( '/var/log/definition.log', 4, pretty => 1, canonical => 1 ); $logger->log('info', 'Lets log JSON lines.'); $logger->emerg({ message => 'emergency', definition => [ 'a serious, unexpected, and often dangerous situation requiring immediate action.' ] }); $logger->alert({ message => 'alert', definition => [ 'quick to notice any unusual and potentially dangerous or difficult circumstances; vigilant.' ] }); $logger->crit({ message => 'critical', definition => [ 'expressing adverse or disapproving comments or judgements.' ] }); $logger->err({ message => 'error', definition => [ 'the state or condition of being wrong in conduct or judgement.' ] }); # the below will not log as the severity level is set to 4 (error) $logger->warning({ message => 'warning', definition => [ 'a statement or event that warns of something or that serves as a cautionary example.' ] }); $logger->notice({ message => 'notice', definition => [ 'the fact of observing or paying attention to something.' ] }); $logger->info({ message => 'information', definition => [ 'what is conveyed or represented by a particular arrangement or sequence of things.' ] }); $logger->debug({ message => 'debug', definition => [ 'identify and remove errors from (computer hardware or software).' ] });
This module is a simple logger that encodes data in JSON Lines format.
JSON Lines is a convenient format for storing structured data that may be processed one record at a time. It works well with unix-style text processing tools and shell pipelines. It's a great format for log files. It's also a flexible format for passing messages between cooperating processes.
https://jsonlines.org
Instantiate a new Log::JSON::Lines object. This expects a filename and optionally a level which value is between 0 to 8 and params that will be passed through to instantiate the JSON::Lines object.
my $logger = Log::JSON::Lines->new($filename, $severity_level, %JSON::Lines::params);
Returns the current log file name.
$logger->file();
Returns the severity level mapping.
$logger->levels();
Returns the current severity level.
$logger->level();
Returns the JSON::Lines object used to encode the line.
$logger->jsonl();
Log a message to the specified log file. This expects a severity level to be passed and either a string message or hashref containing information that you would like to log.
$logger->log($severity, $message);
Log a emerg line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->emerg($message);
Log a alert line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->alert($message);
Log a critical line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->crit($message);
Log a error line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->err($message);
Log a warning line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->warning($message);
Log a notice line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->notice($message);
Log a info line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->info($message);
Log a debug line to the specified log file. This expects either a string or hashref containing information that you would like to log.
$logger->debug($message);
LNATION, <email at lngation.org>
<email at lngation.org>
Please report any bugs or feature requests to bug-log-json-lines at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-JSON-Lines. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-log-json-lines at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Log::JSON::Lines
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-JSON-Lines
CPAN Ratings
https://cpanratings.perl.org/d/Log-JSON-Lines
Search CPAN
https://metacpan.org/release/Log-JSON-Lines
This software is Copyright (c) 2020->2021 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Log::JSON::Lines, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::JSON::Lines
CPAN shell
perl -MCPAN -e shell install Log::JSON::Lines
For more information on module installation, please visit the detailed CPAN module installation guide.