<?sphp $this->text('pagetitle') ?>
 
Home of the Squeezebox™ & Transporter® network music players.

Debugging

From SqueezeboxWiki

Jump to: navigation, search

SqueezeCenter 7.0 and higher use Log::Log4perl for all logging/debugging.

Features:

  • Persistent debugging settings across restarts (very useful for support).
  • Debugging categories with inheritance and multiple log levels. Things like –d_slimproto_v have gone away, to be replaced by a category of network.protocol.slimproto at the DEBUG log level.
  • Plugins can register their own categories which will show up in the Debugging Settings page, and are usable from the command line:
use Slim::Utils::Log;
my $log = Slim::Utils::Log->addLogCategory({
    'category' => 'plugin.itunes',
    'defaultLevel' => 'WARN',
});

Replacing itunes with your plugin's name. You can then use Log::Log4perl calls on your $log object.

  • For quick warnings, etc call:
logWarning("Foo!"); 

or

logError("Bar");

There's also a

logBacktrace("Arrr!");

Note that no newline is needed.


The old –d_foo options have been removed.

Logging now has categories and levels.

A level is one of: OFF, FATAL, ERROR, WARN, INFO or DEBUG.

Here is a rough mapping of old options to new ones.

... in progress.

  • It is vitally important that debugging code not be long running in order that the performance of the server not be adversely affected by the debugging. If a debug operation (for example logging data which must be formatted before being stored) will take a a significant period of time you should check whether debugging is enabled before performing the long running operation. For example:
$log->debug(sub { return Data::Dumper::dump($DBp); } );

is more efficient than:

$log->debug(Data::Dumper::dump($DBp));

(the former case will only generate data if debugging is required by the log4perl code) Alternatively, this can be achieved through conditional execution:

$log->debug(Data::Dumper::dump($DBp)) if ($log->is_debug);

For more comments, quantitative analysis of debugging performance issues, and best practice suggestions, see this forum post by Andy Grundman: http://forums.slimdevices.com/showthread.php?t=38589

Command line options

Log levels may be set at server start through the command line option: –debug. This is a single string which may include multiple entries for log levels separated by commas (no space).

Each entry is of the form <category>=<level>.

'persist' may also be added to set a flag which will persist these levels and any other changes made from the web interface.

./slimserver --debug prefs=WARN,plugin.itunes=INFO,persist