Skip to content

Instantly share code, notes, and snippets.

@simonamor
Created September 14, 2020 11:08
Show Gist options
  • Select an option

  • Save simonamor/3a39d3ceb7bb1521f3ea7e0dff63cffa to your computer and use it in GitHub Desktop.

Select an option

Save simonamor/3a39d3ceb7bb1521f3ea7e0dff63cffa to your computer and use it in GitHub Desktop.
partial content of MyApp.pm
package MyApp;
...
use Catalyst qw/
ConfigLoader
Static::Simple
Authentication
Authorization::Roles
Session
Session::Store::DBI
Session::State::Cookie
StatusMessage
/;
extends 'Catalyst';
...
my $l4pconf = <<EOF;
log4perl.rootLogger=DEBUG,Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr = 0
log4perl.appender.Screen.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %m%n
EOF
# $c->log is handled by Log4Perl so if catalyst debug mode isn't on,
# we need to adjust the config used to make Log4Perl only log INFO and above.
unless (__PACKAGE__->debug) {
warn "Switching to INFO log only :" . __PACKAGE__->debug . ":";
$l4pconf =~ s/DEBUG/INFO/;
}
__PACKAGE__->log( Log::Log4perl::Catalyst->new(\$l4pconf) );
....
# Start the application
__PACKAGE__->setup();
__PACKAGE__->log->levels( qw/info warn error fatal/ ) unless __PACKAGE__->debug;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment