diff --git a/Anvil/Tools.pm b/Anvil/Tools.pm index 7abe9bf4..ae745ae4 100755 --- a/Anvil/Tools.pm +++ b/Anvil/Tools.pm @@ -122,6 +122,8 @@ sub new TEMPLATE => Anvil::Tools::Template->new(), WORDS => Anvil::Tools::Words->new(), VALIDATE => Anvil::Tools::Validate->new(), + # This is to be removed before development ends. + log_file => "", }, DATA => {}, 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 }}); + # Close the log file. + if ($anvil->{HANDLE}{log_file}) + { + close $anvil->{HANDLE}{log_file}; + $anvil->{HANDLE}{log_file} = ""; + } + exit($exit_code); } diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 2cfd254f..e9058ecc 100755 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -3665,6 +3665,8 @@ sub resync_databases # psql -E scancore <<-- LOVE <3 + die $THIS_FILE." ".__LINE__."; testing...\n"; + return(0); } diff --git a/Anvil/Tools/Log.pm b/Anvil/Tools/Log.pm index 6c93c375..df89cf95 100755 --- a/Anvil/Tools/Log.pm +++ b/Anvil/Tools/Log.pm @@ -302,14 +302,35 @@ sub entry } # Log with Log::Journald - Log::Journald::send( - PRIORITY => $priority, - MESSAGE => $string, - CODE_FILE => $source, - CODE_LINE => $line, - SYSLOG_FACILITY => $secure ? "authpriv" : $facility, - SYSLOG_IDENTIFIER => $tag, - ); + if (0) + { + Log::Journald::send( + PRIORITY => $priority, + MESSAGE => $string, + CODE_FILE => $source, + CODE_LINE => $line, + SYSLOG_FACILITY => $secure ? "authpriv" : $facility, + 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); }