NAME
Squatting::With::Log - a simple error log for Squatting apps
SYNOPSIS
Adding simple logging to your Squatting app:
use App 'With::Log', 'On::CGI';
This will let log from within your controllers:
C(
Day => [ '/(\d+)/(\d+)/(\d+)' ],
get => sub {
my ($self, $year, $month, $day) = @_;
my $log = $self->log;
$log->debug(" year: $year");
$log->info ("month: $month");
$log->warn (" day: $day");
# you also get $log->error and $log->fatal
$self->render('day');
}
)
DESCRIPTION
Squatting::With::Log provides a simple logging object that can be used from within your controllers to send messages to either a log file or STDERR for informational purposes. Typically, these messages would be useful during development and debugging but would be disabled for production use.
To use this module, pass the string 'With::Log'
to the use
statement that loads your Squatting app.
CONFIGURATION
Squatting apps may set the following values in their %CONFIG
hash to control the behavior of this module.
- with.log.path
-
This should be a string that specifies the full path to where you want the logs to be sent.
Example:
$CONFIG{'with.log.path'} = "/tmp/error_log";
- with.log.levels
-
This should be a comma-separated string that lists all the log levels you want to enable.
Example: Only output messages with a log level of
error
orfatal
.$CONFIG{'with.log.levels'} = "error,fatal";
API
Object Construction
$log = Squatting::Log->new(\%config)
Configuration
$log->enable(@levels)
This method enables the list of log levels you send it.
$log->disable(@levels)
This method disables the list of log levels you send it.
Introspection
$log->is_debug
$log->is_info
$log->is_warn
$log->is_error
$log->is_fatal
These methods return true if their respective log levels are enabled.
Logging
$log->debug(@messages)
$log->info(@messages)
$log->warn(@messages)
$log->error(@messages)
$log->fatal(@messages)
These methods output the list of log messages you send it using the specified log level.
SEE ALSO
Catalyst::Log - The Squatting::Log API is the same as the Catalyst::Log API.