CGI-Application-Framework
view release on metacpan or search on metacpan
lib/CGI/Application/Framework.pm view on Meta::CPAN
#
# $self->template($self->template_config_name)->fill('some_page', \%tmplvars);
#
# Can be overridden in your application.
# Returns the name of the CGI::Application::Plugin::AnyTemplate
# config to be used for normal templates within the application
#
# By default, this is left undefined, which means you can use the more
# convenient 'unnamed' form:
#
# $self->template->fill('page', \%params);
#
# -------------------------------------------------------
sub template_config_name {
undef;
}
# -------------------------------------------------------
# system_template_config_name
#
# $self->template($self->system_template_config_name)->fill('some_page', \%tmplvars);
#
# Can be overridden in your application.
# Returns the name of the CGI::Application::Plugin::AnyTemplate
# config to be used for system templates within the application
#
# By default, this is 'caf_system_templates'
#
# -------------------------------------------------------
sub system_template_config_name {
'caf_system_templates';
}
# ----------------------------------------------------------
# Initialize the logging subsystem
# ----------------------------------------------------------
sub _log_init {
my $self = shift;
my $config = $self->conf($self->config_name)->context;
# ----------------------------------------------------------
# Set up a logging object and use it everywhere!
# ----------------------------------------------------------
my $log_config = $config->{'LogDispatch'};
my $log_names = $log_config->{'LogName'} || {};
my @log_modules;
foreach my $name (keys %$log_names) {
$log_names->{$name}{'name'} ||= $name;
push @log_modules, $log_names->{$name};
}
my %log_options = (
LOG_DISPATCH_MODULES => \@log_modules,
);
if ($log_config->{'format'}) {
my @callbacks = @{ $log_config->{'options'}{'callbacks'} ||= [] };
push @callbacks, Log::Dispatch::Config->format_to_cb($log_config->{'format'});
$log_config->{'options'}{'callbacks'} = \@callbacks;
}
if ($log_config->{'options'}) {
$log_options{'LOG_DISPATCH_OPTIONS'} = $log_config->{'options'};
}
if ($log_config->{'append_newline'}) {
$log_options{'APPEND_NEWLINE'} = 1;
}
$self->log_config(%log_options);
$self->log->debug("logging system initialized: (pid: $$)");
}
sub log_croak {
my $self = shift;
$Carp::CarpLevel = 1;
my $message = Carp::shortmess(@_);
$self->log->emergency($message);
die $message;
}
sub log_carp {
my $self = shift;
$Carp::CarpLevel = 1;
my $message = Carp::shortmess(@_);
$self->log->warning($message);
warn $message;
}
sub log_confess {
my $self = shift;
$Carp::CarpLevel = 1;
my $message = Carp::longmess(@_);
$self->log->emergency($message);
die $message;
}
sub log_cluck {
my $self = shift;
$Carp::CarpLevel = 1;
my $message = Carp::longmess(@_);
$self->log->warning($message);
warn $message;
}
sub _framework_postrun {
my $self = shift;
$self->log->debug(
"In 'cgiapp_postrun', the current run mode is : "
. $self->get_current_runmode()
);
# ------------------------------------------------------------
# "touch" the timestamp within the persistent session hash for
# this session (ultimately derived from / tied together with
# the 'session_id' cookie. This is important with regards to
# the time-out (via _relogin_test) system.
# ------------------------------------------------------------
( run in 0.506 second using v1.01-cache-2.11-cpan-39bf76dae61 )