NAME

Log::JSON::Lines - Log in JSONLines format

VERSION

Version 1.00

SYNOPSIS

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).'
	]
});

DESCRIPTION

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

SUBROUTINES/METHODS

new

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);

file

Returns the current log file name.

$logger->file();

levels

Returns the severity level mapping.

$logger->levels();

level

Returns the current severity level.

$logger->level();

jsonl

Returns the JSON::Lines object used to encode the line.

$logger->jsonl();

log

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);

emerg - 1

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);

alert - 2

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);

crit - 3

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);

err - 4

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);

warning - 5

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);

notice - 6

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);

info - 7

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);

debug - 8

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);

AUTHOR

LNATION, <email at lngation.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Log::JSON::Lines

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020->2021 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)