in reply to Debugging in packages

A better approach IMHO is to have a centralized messaging/logging/debugging method or function that takes a message and a priority number, and use that in your code instead of calling print().

Then you can set the debugging level (e.g., with an environment variable, or a configuration option, or even just an option or an argument), and if the current debugging level exceeds or is equal to the priority number of a message, the message will be printed to STDERR, or logged to a file, or whatever.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

Replies are listed 'Best First'.
($code or die) Re: Debugging in packages
by $code or die (Deacon) on Jul 17, 2001 at 18:15 UTC
    I was looking at Devel::Messenger this morning. It looks like it does this. You can have debug levels and print certain messages only if debugging is on or above that level. It will print to files\filehandles as well. I haven't tried it yet though.

    Error: Keyboard not attached. Press F1 to continue.

      For production servers on Unix, a good idea is to use Sys::Syslog. On Windows, the equivalent would be Win32::EventLog.

      Christian Lemburg
      Brainbench MVP for Perl
      http://www.brainbench.com