Changed exit code so error modules are created

This commit is contained in:
Kevin 2021-02-05 13:07:54 +01:00
parent 64d27c6572
commit b657138fad
1 changed files with 13 additions and 12 deletions

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.752"; my $pandora_version = "7.0NG.752";
my $pandora_build = "210205"; my $pandora_build = "210202";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );
@ -959,7 +959,7 @@ sub print_error {
if (is_enabled($conf->{'as_server_plugin'})) { if (is_enabled($conf->{'as_server_plugin'})) {
print STDERR $msg . "\n"; print STDERR $msg . "\n";
print $value . "\n"; print $value . "\n";
exit 1; exit 0;
} }
print_module($conf, { print_module($conf, {
@ -968,7 +968,7 @@ sub print_error {
value => $value, value => $value,
desc => $msg, desc => $msg,
}); });
exit 1; exit 0;
} }
################################################################################ ################################################################################
@ -991,16 +991,17 @@ sub logger {
my ($conf, $tag, $message) = @_; my ($conf, $tag, $message) = @_;
my $file = $conf->{'log'}; my $file = $conf->{'log'};
print_error($conf, "[ERROR] Log file is not defined.", 0, 1) unless defined($file); print_error($conf, "[ERROR] Log file is not defined. exit 1;
# Log rotation
if (defined($file) && -e $file && (stat($file))[7] > 32000000) {
rename ($file, $file.'.old');
} }
my $LOGFILE;
if ($log_aux_flag == 0) { print_module($conf, {
# Log starts name => (empty($conf->{'global_plugin_module'})?"Plugin execution result " . $0:$conf->{'global_plugin_module'}),
if (! open ($LOGFILE, "> $file")) { type => "generic_proc",
value => $value,
desc => $msg,
});
exit 1;
{
print_error ($conf, "[ERROR] Could not open logfile '$file'", 0, 1); print_error ($conf, "[ERROR] Could not open logfile '$file'", 0, 1);
} }
$log_aux_flag = 1; $log_aux_flag = 1;