XAS::Lib::App - The base class to write procedures within the XAS environment
use XAS::Lib::App; my $app = XAS::Lib::App->new(); $app->run();
This module defines a base class for writing procedures. It provides a logger, signal handling, options processing along with a exit handler.
This method initilaizes the module. It takes several parameters:
This changes the default error message from "changeme" to something useful.
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=s' => 'test.log' } ] );
This will then create an accessor named "logfile" that will return the value, which may be the supplied default or supplied from the command line.
This will change the facility of the alert. The default is 'systems'.
This will change the priority of the alert. The default is 'high'.
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.
This method sets up a global exception handler and calls main(). The main() method will be passed one parameter: an initialised handle to this class.
sub main { my $self = shift; $self->log->debug('in main'); }
If an exception is caught, the global exception handler will send an alert, write the exception to the log and returns an exit code of 1.
When the procedure completes successfully, it will return an exit code of 0.
To change this behavior you would need to override the exit_handler() method.
This method sets up the logger. By default, this logs to stderr.
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, } ); }
This method sets up basic signal handling. By default this is only for the INT and QUIT signals.
sub define_signals { my $self = shift; $SIG{INT} = \&signal_handler; $SIG{QUIT} = \&singal_handler; }
This method is a default signal handler. By default it throws an exception. It takes one parameter.
The signal that was captured.
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.
This should be an execption object, usually a XAS::Exception. The exeception is formated to a string and printed to log.
This module has several accessors that make life easier for you.
This is the handle to the XAS logger.
This is the handle to the XAS Alert system.
This is the handle to the XAS environment.
These mutator are provided to help control the process.
The facility to use when sending an alert.
The priority of the alert.
This module handles the following command line options.
This toggles debugging output.
This toggles sending alerts. They are on by default.
This prints out a short help message based on the procedures pod.
This displaces the procedures manual in the defined pager.
This prints out the version of the module.
XAS
Kevin L. Esteb, <kevin@kesteb.us>
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.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.