added logging capability to spectre
This commit is contained in:
parent
350f3908e6
commit
c713d5f50c
3 changed files with 86 additions and 12 deletions
|
|
@ -81,6 +81,20 @@ sub debug {
|
|||
if ($self->{_debug}) {
|
||||
print "ADMIN: ".$output."\n";
|
||||
}
|
||||
$self->getLogger->debug("ADMIN: ".$output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head3 getLogger ( )
|
||||
|
||||
Returns a reference to the logger.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLogger {
|
||||
my $self = shift;
|
||||
return $self->{_logger};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -103,7 +117,10 @@ sub new {
|
|||
my $class = shift;
|
||||
my $config = shift;
|
||||
my $debug = shift;
|
||||
my $self = {_debug=>$debug, _config=>$config};
|
||||
Log::Log4perl->init( $config->getWebguiRoot."/etc/log.conf" );
|
||||
$Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth+3;
|
||||
my $logger = Log::Log4perl->get_logger($config->getFilename);
|
||||
my $self = {_debug=>$debug, _config=>$config, _logger=>$logger};
|
||||
bless $self, $class;
|
||||
create_ikc_server(
|
||||
port => $config->get("port"),
|
||||
|
|
@ -113,8 +130,8 @@ sub new {
|
|||
object_states => [ $self => {_start=>"_start", _stop=>"_stop", "shutdown"=>"_stop"} ],
|
||||
args=>[["shutdown"]]
|
||||
);
|
||||
$self->{_workflow} = Spectre::Workflow->new($config, $debug);
|
||||
$self->{_cron} = Spectre::Cron->new($config, $self->{_workflow}, $debug);
|
||||
$self->{_workflow} = Spectre::Workflow->new($config, $logger, $debug);
|
||||
$self->{_cron} = Spectre::Cron->new($config, $logger, $self->{_workflow}, $debug);
|
||||
POE::Kernel->run();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,7 @@ sub debug {
|
|||
if ($self->{_debug}) {
|
||||
print "CRON: ".$output."\n";
|
||||
}
|
||||
$self->getLogger->debug("CRON: ".$output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -282,6 +283,19 @@ sub deleteJob {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head3 getLogger ( )
|
||||
|
||||
Returns a reference to the logger.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLogger {
|
||||
my $self = shift;
|
||||
return $self->{_logger};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadSchedule ( config )
|
||||
|
|
@ -309,7 +323,7 @@ sub loadSchedule {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( config )
|
||||
=head2 new ( config, logger, workflow, [ debug ] )
|
||||
|
||||
Constructor.
|
||||
|
||||
|
|
@ -317,7 +331,11 @@ Constructor.
|
|||
|
||||
A WebGUI::Config object that represents the spectre.conf file.
|
||||
|
||||
=head3 workflowSession
|
||||
=head3 logger
|
||||
|
||||
A reference to the logger object.
|
||||
|
||||
=head3 workflow
|
||||
|
||||
A reference to the Worfklow session.
|
||||
|
||||
|
|
@ -330,9 +348,10 @@ A boolean indicating Spectre should spew forth debug as it runs.
|
|||
sub new {
|
||||
my $class = shift;
|
||||
my $config = shift;
|
||||
my $logger = shift;
|
||||
my $workflowSession = shift;
|
||||
my $debug = shift;
|
||||
my $self = {_debug=>$debug, _workflowSession=>$workflowSession, _config=>$config};
|
||||
my $self = {_debug=>$debug, _workflowSession=>$workflowSession, _config=>$config, _logger=>$logger};
|
||||
bless $self, $class;
|
||||
my @publicEvents = qw(addJob deleteJob);
|
||||
POE::Session->create(
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ sub debug {
|
|||
if ($self->{_debug}) {
|
||||
print "WORKFLOW: ".$output."\n";
|
||||
}
|
||||
$self->getLogger->debug("WORKFLOW: ".$output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -197,6 +198,38 @@ sub deleteInstance {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 error ( output )
|
||||
|
||||
Prints out error information if debug is enabled.
|
||||
|
||||
=head3
|
||||
|
||||
=cut
|
||||
|
||||
sub error {
|
||||
my $self = shift;
|
||||
my $output = shift;
|
||||
if ($self->{_debug}) {
|
||||
print "WORKFLOW: ".$output."\n";
|
||||
}
|
||||
$self->getLogger->error("WORKFLOW: ".$output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head3 getLogger ( )
|
||||
|
||||
Returns a reference to the logger.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLogger {
|
||||
my $self = shift;
|
||||
return $self->{_logger};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNextInstance ( )
|
||||
|
||||
=cut
|
||||
|
|
@ -235,13 +268,17 @@ sub loadWorkflows {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( config [ , debug ] )
|
||||
=head2 new ( config, logger, [ , debug ] )
|
||||
|
||||
Constructor. Loads all active workflows from each WebGUI site and begins executing them.
|
||||
|
||||
=head3 config
|
||||
|
||||
The path to the root of the WebGUI installation.
|
||||
The config object for spectre.
|
||||
|
||||
=head3 logger
|
||||
|
||||
A reference to the logger object.
|
||||
|
||||
=head3 debug
|
||||
|
||||
|
|
@ -252,8 +289,9 @@ A boolean indicating Spectre should spew forth debug as it runs.
|
|||
sub new {
|
||||
my $class = shift;
|
||||
my $config = shift;
|
||||
my $logger = shift;
|
||||
my $debug = shift;
|
||||
my $self = {_debug=>$debug, _config=>$config};
|
||||
my $self = {_debug=>$debug, _config=>$config, _logger=>$logger};
|
||||
bless $self, $class;
|
||||
my @publicEvents = qw(addInstance deleteInstance);
|
||||
POE::Session->create(
|
||||
|
|
@ -365,16 +403,16 @@ sub workerResponse {
|
|||
$self->debug("Workflow instance $instanceId is now complete.");
|
||||
$kernel->yield("deleteInstance",$instanceId);
|
||||
} elsif ($state eq "error") {
|
||||
$self->debug("Got an error for $instanceId.");
|
||||
$self->debug("Got an error response for $instanceId.");
|
||||
$kernel->yield("suspendInstance",$instanceId);
|
||||
} else {
|
||||
$self->debug("Something bad happened on the return of $instanceId. ".$response->error_as_HTML);
|
||||
$self->error("Something bad happened on the return of $instanceId. ".$response->error_as_HTML);
|
||||
$kernel->yield("suspendInstance",$instanceId);
|
||||
}
|
||||
} elsif ($response->is_redirect) {
|
||||
$self->debug("Response for $instanceId was redirected.");
|
||||
} elsif ($response->is_error) {
|
||||
$self->debug("Response for $instanceId had a communications error. ".$response->error_as_HTML);
|
||||
$self->error("Response for $instanceId had a communications error. ".$response->error_as_HTML);
|
||||
$kernel->yield("suspendInstance",$instanceId)
|
||||
# we should probably log something
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue