From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Data::AnyXfer::Elastic::Logger

SYNOPSIS

my $logger = Data::AnyXfer::Elastic::Logger->new(
dir => 'Str|Path::Class::Dir', # optional
options => { # optional
screen => {},
file_rotate => {},
},
screen => 0, # false by default
file => 1, # true by default
);
# alias = employees
my $datafile1 = Datafile->new( file => 'employees.datafile' );
# by default will log to ../elasticsearch/logs/dd-mm-yyyy/employees
$logger->debug(
index_info => $datafile1,
text => 'Blah Blah Blah!',
content => \@errors
);
# alias = interiors
my $datafile2 = Datafile->new( file => 'interiors.datafile' );
# by default will log to ../elasticsearch/logs/dd-mm-yyyy/interiors
$logger->critical(
index_info => $datafile2,
text => 'Oops! Something went wrong!',
content => Search::Elasticsearch::Error::Request->new;
);

DESCRIPTION

This module is based of Log::Dispatch to log Elasticsearch events and errors.

ATTRIBUTES

destination

Defines the directory location of logging. Defaults to CWD/logs/yyyy-mm-dd/alias_name.

file

Log to file. Defaults to true.

screen

Log to screen. Defaults to false.

options

These define the options for Log::Dispatch::Screen and Log::Dispatch::Screen please refer to their documentation. Note that for FileRotate the arguement filename will be overwritten.

Must be in the format:

{
screen => { Log::Dispatch::Screen options }
file_rotate => { Log::Dispatch::FileRotate options }
}

METHODS

Logging:

my %args = ( index_info => $df, text => '', content => $struct );
$logger->debug( %args );
$logger->info( %args );
$logger->notice( %args );
$logger->warning( %args );
$logger->error( %args );
$logger->critical( %args );
$logger->alert( %args );
$logger->emergency( %args );

All logging methods have the arguements: index_info, text and content. Content can be either a perl data structure or a Search::Elasticsearch::Error::Request object.

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.