NAME
XAS::Lib::App - The base class to write procedures within the XAS environment
SYNOPSIS
use XAS::Lib::App;
my $app = XAS::Lib::App->new();
$app->run();
DESCRIPTION
This module defines a base class for writing procedures. It provides a logger, signal handling, options processing along with a exit handler.
METHODS
new
This method initilaizes the module. It takes several parameters:
- -throws
-
This changes the default error message from "changeme" to something useful.
- -options
-
This will parse additional options from the command line. Those options are a list of command line options and defaults.
Example
my $app = XAS::Lib::App->new( -options => [ { -logfile => 'test.log' } ] );
This will then create an accessor named "logfile" that will return the value, which may be the supplied default or suppliced from the command line.
- -facility
-
This will change the facility of the alert. The default is 'systems'.
- -priority
-
This will change the priority of the alert. The default is 'high'.
- -alerts
-
This will toggle wither to send an alert to the XAS Alert System. The default is to do so. Values of 'true', 'yes' or 1 will evaluate to TRUE.
run
This method sets up a global exception handler and calls main(). It will return an exit code for the command line. By default this is 0 for success and 1 for failure. This can be overridden in the exit_handler() method.
define_logging
This method sets up the logger. By default, this logs to stderr.
Example
sub define_logging {
my $self = shift;
my $logfile = defined($self->logfile) ?
$self->logfile :
$self->env->logfile;
$self->{log} = XAS::System->module(
logger => {
-filename => $logfile,
-debug => $debug,
}
);
}
define_signals
This method sets up basic signal handling. By default this is only for the INT and QUIT signals.
Example
sub define_signals {
my $self = shift;
$SIG{INT} = \&signal_handler;
$SIG{QUIT} = \&singal_handler;
}
signal_handler($signal)
This method is a default signal handler. By default it throws an exception. It takes one parameter.
exit_handler($ex)
This method is the default exit handler for any procedure within the XAS environment. It will write an entry to the log file and send an alert.
- $ex
-
This should be an execption object, usually a XAS::Exception. The exeception is formated to a string and printed to log.
ACCESSORS
This module has several accessors that make life easier for you.
log
This is the handle to the XAS logger.
alert
This is the handle to the XAS Alert system.
env
This is the handle to the XAS environment.
MUTATORS
These mutator are provided to help control the process.
facility
The facility to use when sending an alert.
priority
The priority of the alert.
OPTIONS
This module handles the following command line options.
--debug
This toggles debugging output.
--alerts
This toggles sending alerts. They are on by default.
--help
This prints out a short help message based on the procedures pod.
--manual
This displaces the procedures manual in the defined pager.
--version
This prints out the version of the module.
SEE ALSO
XAS::Base
XAS::Class
XAS::Constants
XAS::Exception
XAS::System
XAS::Utils
XAS::Apps::Base::Alerts
XAS::Apps::Base::Collector
XAS::Apps::Base::ExtractData
XAS::Apps::Base::ExtractGlobals
XAS::Apps::Base::RemoveData
XAS::Apps::Database::Schema
XAS::Apps::Templates::Daemon
XAS::Apps::Templates::Generic
XAS::Apps::Test::Echo::Client
XAS::Apps::Test::Echo::Server
XAS::Apps::Test::RPC::Client
XAS::Apps::Test::RPC::Methods
XAS::Apps::Test::RPC::Server
XAS::Collector::Alert
XAS::Collector::Base
XAS::Collector::Connector
XAS::Collector::Factory
XAS::Lib::App
XAS::Lib::App::Daemon
XAS::Lib::App::Daemon::POE
XAS::Lib::Connector
XAS::Lib::Counter
XAS::Lib::Daemon::Logger
XAS::Lib::Daemon::Logging
XAS::Lib::Gearman::Admin
XAS::Lib::Gearman::Admin::Status
XAS::Lib::Gearman::Admin::Worker
XAS::Lib::Gearman::Client
XAS::Lib::Gearman::Client::Status
XAS::Lib::Gearman::Worker
XAS::Lib::Net::Client
XAS::LIb::Net::Server
XAS::Lib::RPC::JSON::Client
XAS::Lib::RPC::JSON::Server
XAS::Lib::Session
XAS::Lib::Spool
XAS::Model::Database
XAS::Model::Database::Alert
XAS::Model::Database::Counter
XAS::Model::DBM
XAS::Monitor::Base
XAS::Monitor::Database
XAS::Monitor::Database::Alert
XAS::Scheduler::Base
XAS::System::Alert
XAS::System::Email
XAS::System::Environment
XAS::System::Logger
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Kevin L. Esteb
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.