NAME

Konstrukt::Debug - Debug and error message handling

SYNOPSIS

        use Konstrukt::Debug;
        $Konstrukt::Debug->debug_message("message") if Konstrukt::Debug::DEBUG;
        $Konstrukt::Debug->error_message("message") if Konstrukt::Debug::ERROR;

DESCRIPTION

This module offers two general classes of debug-messages: debug and error. Additionally there are 5 constants (ERROR, WARNING, INFO, NOTICE, DEBUG) which determine how noisy the debug output will be. See "CONFIGURATION" for details on that.

This should be enough for most purposes. A too complex system like log4perl would be overkill for our purposes.

This module will determine the package and method, from which the message has been sent automatically and print it out.

The messages get collected and may be printed out on demand.

CONFIGURATION

Defaults:

        #warn() the messages. this may be useful to put them in a server log.
        debug/warn_debug_messages 0
        debug/warn_error_messages 1
        
        #don't provide additional information on the error source
        debug/short_messages      1
        
        #put the messages into a permanent log (using the log plugin)
        debug/log_debug_messages  0
        debug/log_error_messages  0

You can also define the "noisiness" of the debug messages. In the head of the source of this module you can turn on (and off) these constants:

  • Konstrukt::Debug::ERROR

  • Konstrukt::Debug::WARNING

  • Konstrukt::Debug::INFO

  • Konstrukt::Debug::NOTICE

  • Konstrukt::Debug::DEBUG

You should alsway use these constants as conditionals for your debug output as described above. This has the advantage that the code for your debug messages will be completely removed during compilation when the according debug constant is set to 0. This will lead to a major performance increase.

As a default ERROR, WARNING and INFO are set to 1, the other ones are set to 0.

METHODS

new

Constructor of this class

init

Initialization of this class

error_message

Will put the error message on the stack and prevent caching of the current file as there were errors.

Parameters:

  • $message - The error message

  • $exit - Should be true when there was a critical error and the further processing should be interrupted.

debug_message

Collects some useful but not essentially neccessary information.

Parameters:

  • $message - The debug message

format_error_messages

Joins all error messages in a string returns them.

format_debug_messages

Joins all debug messages in a string returns them.

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

Konstrukt