Skip to content

Instantly share code, notes, and snippets.

@sycobuny
Created February 2, 2012 17:40
Show Gist options
  • Save sycobuny/1724800 to your computer and use it in GitHub Desktop.
Save sycobuny/1724800 to your computer and use it in GitHub Desktop.
Demonstrating the "Scribe" Logger
#!/usr/bin/perl
use warnings;
use strict;
use Scribe;
my ($logger) = Scribe->new(
minlog => Scribe::DEBUG6,
standard => {
use_color => 1,
use_stdout => 1,
use_stderr => 1,
},
syslog => {
use_syslog => 1,
ident => 'test script',
facility => 'user',
error => {
use_error_syslog => 0,
ident => 'test script_errors',
facility => 'user',
},
},
file => {
messages => {
append => 1,
path => 'test.log',
permissions => 0777,
},
errors => {
append => 1,
path => 'test.err',
permissions => 0777,
},
},
);
$logger->notice('%:B:This is a blue notice!');
$logger->error('%:Y:This is a yellow error!');
$logger->fatal('%:R:This is a red ~~~FATALITY~~~');
1;
__END__
Console output would look like this (only with colors, natch):
sycobuny@brony ~/test_scribe $ ./test_script.pl
This is a blue notice!
! This is a yellow error!
!!! FATAL: This is a red ~~~FATALITY~~~
syslog output would look like this:
Feb 2 12:36:02 BRONY test script[5554]: <NOTICE> This is a blue notice!
Feb 2 12:36:02 BRONY test script[5554]: <ERR> This is a yellow error!
Feb 2 12:36:02 BRONY test script[5554]: <CRIT> This is a red ~~~FATALITY~~~
test.log output would look like this:
Thu Feb 2 12:36:02 2012 This is a blue notice!
test.err output would look like this:
Thu Feb 2 12:36:02 2012 This is a yellow error!
Thu Feb 2 12:36:02 2012 This is a red ~~~FATALITY~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment