[Slim-Checkins] r10551 - in /trunk/server/Slim/Utils: Log.pm Misc.pm

dsully at svn.slimdevices.com dsully at svn.slimdevices.com
Wed Nov 1 17:55:00 PST 2006


Author: dsully
Date: Wed Nov  1 17:54:59 2006
New Revision: 10551

URL: http://svn.slimdevices.com?rev=10551&view=rev
Log:
Bug: N/A
Description: Check to see if logging is initialized before trying to use it. Fix backtrace message.

Modified:
    trunk/server/Slim/Utils/Log.pm
    trunk/server/Slim/Utils/Misc.pm

Modified: trunk/server/Slim/Utils/Log.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Log.pm?rev=10551&r1=10550&r2=10551&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Log.pm (original)
+++ trunk/server/Slim/Utils/Log.pm Wed Nov  1 17:54:59 2006
@@ -58,6 +58,18 @@
 
 my @validLevels   = qw(OFF FATAL ERROR WARN INFO DEBUG);
 
+=head2 isInitialized( )
+
+Returns true if the logging system is initialized. False otherwise.
+
+=cut
+
+sub isInitialized {
+	my $class = shift;
+
+	return Log::Log4perl->initialized;
+}
+
 =head2 init( )
 
 Initialize the logging subsystem.
@@ -258,11 +270,10 @@
 	$Log::Log4perl::caller_depth++;
 
 	if (scalar @_) {
-		Slim::Utils::Misc::bt();
 		$self->error("Error: ", @_);
 	}
 
-	$self->error("Backtrace: \n", Slim::Utils::Misc::bt(1));
+	$self->error(Slim::Utils::Misc::bt(1));
 
 	$Log::Log4perl::caller_depth--;
 }

Modified: trunk/server/Slim/Utils/Misc.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Misc.pm?rev=10551&r1=10550&r2=10551&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Misc.pm (original)
+++ trunk/server/Slim/Utils/Misc.pm Wed Nov  1 17:54:59 2006
@@ -64,6 +64,7 @@
 		require Win32::File;
 		require Win32::FileOp;
 		require Win32::Process;
+		require Win32::Service;
 		require Win32::Shortcut;
 	}
 }
@@ -408,7 +409,10 @@
 	my $path = $uri->path;
 	my $log  = logger('os.files');
 
-	$log->info("Got $path from file url $url");
+	if (Slim::Utils::Log->isInitialized) {
+
+		$log->info("Got $path from file url $url");
+	}
 
 	# only allow absolute file URLs and don't allow .. in files...
 	if ($path !~ /[\/\\]\.\.[\/\\]/) {
@@ -416,10 +420,13 @@
 		$file = fixPathCase($uri->file);
 	}
 
-	if (!defined($file))  {
-		$log->warn("Bad file: url $url");
-	} else {
-		$log->info("Extracted: $file from $url");
+	if (Slim::Utils::Log->isInitialized) {
+
+		if (!defined($file))  {
+			$log->warn("Bad file: url $url");
+		} else {
+			$log->info("Extracted: $file from $url");
+		}
 	}
 
 	if (!$noCache && scalar keys %fileToPathCache > 32) {
@@ -1127,7 +1134,7 @@
 
 		my $now = substr(int(Time::HiRes::time() * 10000),-4);
 
-		$entry = join("", strftime("%H:%M:%S.", localtime), $now, " $entry");
+		$entry = join("", strftime("[%H:%M:%S.", localtime), $now, "] $entry");
 	}
 
 	if (!$::quiet) {



More information about the checkins mailing list