* Added logging to a plain file to aid in debugging. We will revert to journald logging before first release.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent c21b326f1a
commit 527848de97
  1. 9
      Anvil/Tools.pm
  2. 2
      Anvil/Tools/Database.pm
  3. 21
      Anvil/Tools/Log.pm

@ -122,6 +122,8 @@ sub new
TEMPLATE => Anvil::Tools::Template->new(), TEMPLATE => Anvil::Tools::Template->new(),
WORDS => Anvil::Tools::Words->new(), WORDS => Anvil::Tools::Words->new(),
VALIDATE => Anvil::Tools::Validate->new(), VALIDATE => Anvil::Tools::Validate->new(),
# This is to be removed before development ends.
log_file => "",
}, },
DATA => {}, DATA => {},
ENV_VALUES => { ENV_VALUES => {
@ -339,6 +341,13 @@ sub nice_exit
}}); }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0135", variables => { runtime => $run_time }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0135", variables => { runtime => $run_time }});
# Close the log file.
if ($anvil->{HANDLE}{log_file})
{
close $anvil->{HANDLE}{log_file};
$anvil->{HANDLE}{log_file} = "";
}
exit($exit_code); exit($exit_code);
} }

@ -3665,6 +3665,8 @@ sub resync_databases
# psql -E scancore <<-- LOVE <3 # psql -E scancore <<-- LOVE <3
die $THIS_FILE." ".__LINE__."; testing...\n";
return(0); return(0);
} }

@ -302,6 +302,8 @@ sub entry
} }
# Log with Log::Journald # Log with Log::Journald
if (0)
{
Log::Journald::send( Log::Journald::send(
PRIORITY => $priority, PRIORITY => $priority,
MESSAGE => $string, MESSAGE => $string,
@ -310,6 +312,25 @@ sub entry
SYSLOG_FACILITY => $secure ? "authpriv" : $facility, SYSLOG_FACILITY => $secure ? "authpriv" : $facility,
SYSLOG_IDENTIFIER => $tag, SYSLOG_IDENTIFIER => $tag,
); );
}
else
{
# TODO: Switch back to journald later, using a file for testing for now
if ($string !~ /\n$/)
{
$string .= "\n";
}
# Open the file?
if (not $anvil->{HANDLE}{log_file})
{
my $shell_call = "/var/log/anvil.log";
open (my $file_handle, ">>", $shell_call) or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => $secure, priority => "err", key => "log_0016", variables => { shell_call => $shell_call, error => $! }});
$anvil->{HANDLE}{log_file} = $file_handle;
}
my $file_handle = $anvil->{HANDLE}{log_file};
print $file_handle $string;
}
return(0); return(0);
} }

Loading…
Cancel
Save