use Spong::Daemon;
use Spong::Status qw(status);
+use Spong::Log;
srand( time() ^ ($$ + ($$ << 15 )) );
exit 1;
}
-$debug = $debuglevel;
-
-#if( $ARGV[0] eq "--debug" ) { $debug = 1; shift; }
-#if( $ARGV[0] eq "--restart" ) { $restart = 1; shift; }
-#if( $ARGV[0] eq "--kill" ) { $kill = 1; shift; }
-#if( $ARGV[0] eq "--nosleep" ) { $nosleep = 1; shift; }
-#if( $ARGV[0] eq "--refresh" ) { $nosleep = 1; shift; }
+# Initial debugging for preconfiguration debugging
+Spong::Log::set_debug_context( 'debuglevel' => $debuglevel );
$me = "@@BINDIR@@/spong-network";
$conf_file = $ARGV[0] || "@@ETCDIR@@/spong.conf";
$HOST =~ tr/A-Z/a-z/;
&load_config_files(); # Loads the user specified configuration information
+&init_logging(); # Initialize logging contexts
Spong::Daemon::Daemonize() # Daemonize if not signalling or a one-shot
unless ($nosleep || $restart || $kill || $debug );
&handle_signals(); # Set up handlers, and signal the current server if asked
}
+# This function initializes the debug and error logging contexts in the
+# Log module.
+
+sub init_logging {
+ if (defined $debuglevel) {
+ $debug = ($debuglevel == 0) ? 1 : $debuglevel
+ }
+
+ Spong::Log::set_debug_context( 'debuglevel' => $debug );
+
+ my $filename = ($SPONG_LOG_FILE) ? "$SPONGTMP/spong-network.log" : "";
+ my $syslog = ($SPONG_LOG_SYSLOG) ? 1 : 0;
+
+ Spong::Log::set_error_context( syslog => $syslog,
+ ident => 'spong-network',
+ logopt => 'pid,cons',
+ priority => 'ERR',
+ filename => $filename,
+ );
+}
+
# Load our configuration variables, including anything specific to the host
# that we are running on.
# Output functions, one for debugging information, the other for errors.
-sub debug { print scalar localtime, " ", $_[0], "\n" if $main::debug; }
-sub error { warn scalar localtime(), " Error: ", $_[0], "\n"; }
+sub debug { Spong::Log::debug($_[0],$_[1]); }
+sub error { Spong::Log::error($_[0]); }
# Handle some signals...