Sprog::Debug.3pm

Langue: en

Version: 2005-06-12 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Sprog::Debug - routine for logging debug messages.

SYNOPSIS

   use Sprog::Debug qw($DBG);
 
   ...
 
   $DBG && $DBG->("Some debugging message", $data_ref);
 
 

DESCRIPTION

If Sprog is started with the "--debug" (or "-d") switch, then debugging messages will be logged to sprog.dbg in the current directory.

A module that wants to log debug messages should import the $DBG variable. This scalar will either be undefined (the default) or if debugging was enabled, it will contain a reference to a subroutine.

To log a message, a module should first check that $DBG is defined and if it is should call it, passing a list of messages and/or data references.

Each argument passed to the debug logger will be handled as follows:

*
If the item is a reference rather than a plain scalar will be dumped using YAML.
*
Non-references will simply be written to the log, with a newline appended if the string did not end in one.

The debug logger routine will prepend a timestamp to each line logged.

Copyright 2004-2005 Grant McLean <grantm@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.