Skip to content

Instantly share code, notes, and snippets.

@mephinet
Last active April 22, 2017 21:45
Show Gist options
  • Save mephinet/c1e48e0a6d6bbd5949483e24aeac9961 to your computer and use it in GitHub Desktop.
Save mephinet/c1e48e0a6d6bbd5949483e24aeac9961 to your computer and use it in GitHub Desktop.
sample Log::Any user
use warnings;
use strict;
use Log::Any::Adapter;
use Log::Any '$log';
use File::Basename;
BEGIN { $ENV{LOG_PREFIX} = 'elapsed'; }
Log::Any::Adapter->set( 'Screen', min_level => 'debug' );
$log->infof( '%s starting version %s', basename($0), 0.1 );
$log->debug( 'Checking config files in these locations',
[qw(/etc ~/.config ~/.local)] );
$log->warning('no config file found, using defaults');
$log->debug( 'Current settings:',
{ verbose => 0, pretty => 0, create_backup => 1, } );
$log->info('Performing my work...');
sleep 2;
$log->info( 'Processed all files', { files => 42, cumulated_size => '2GB' } );
$log->error( 'Found file over limit',
{ limit => '4GB', file => '/path/to/file', size => '4.2GB' } );
$log->info('Done');
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment