mrerror__define.pro
mrError
Description:
An object to provide logging and error handling functionality.
Logging is relatively straight forward. Once instanciated (where
it is defined whether output should go to a file or stdout), the
object provides log, warn, err and fatal methods which will create
a corresponding message line in the output file.
For warn and err messages, the user may set a certain limit after
which the program is terminated. fatal messages always lead to
immediate program termination.
The user may also register objects for callback and/or destruction
at the time of program termination. Objects registered for callback
must provide a procedure named 'fatal'.
Objects are called before program termination in reverse order in
which they were registered.
Constructors and destructor
mrError__define : constructor, 1st part
mrError::init : constructor, 2nd part
mrError::cleanup : the destructor
General
mrError::log : print informational message
mrError::warn : print warning message
mrError::error : print error message
mrError::fatal : print fatal message and exit
mrError::add : add object to callback and/or destroy list
mrError::remove : remove object from lists
Private methods
mrError::mess : called by all log methods
mrError::terminateProg : handles callback at program termination
mrError::init
Syntax:
obj = obj_new('mrerror', file, /append, warnlimit=w, errlimit=e )
Arguments:
file
If present, output will go to the given filename, otherwise it
will be printed to stdout.
append
If set, append to a possibly existing file.
warnlimit
Maximum number of warning messages before program is terminated.
Default is '0', which means that warning messages never lead to
program termination.
errlimit
Maximum number of error messages before program is terminated.
Description:
Instanciates an mrError object. If a filename is present, but
opening fails, the object will not be created.
mrError::cleanup
Description:
The destructor - clears and destroys the container objects
mrError::log
Syntax:
obj->log, message [, origin]
Arguments:
message
The message to print
origin
Optional argument denoting the origin of the message. May be a
string or an object, in which case the class name is printed as
origin.
Description:
Print an informational message
mrError::warn
Syntax:
obj->warn, message [, origin]
Arguments:
see mrError::log
Description:
Print a warning message
mrError::error
Syntax:
obj->error, message [, origin]
Arguments:
see mrError::log
Description:
Prints the given error message and a stackdump
mrError::fatal
Syntax:
obj->fatal, message [, origin]
Arguments:
see mrError::log
Description:
Print 'FATAL' message and stacktrace and terminate program
mrError::add
Syntax:
obj->add, obj, /fatal, /destroy
Arguments:
obj
The object to add
fatal and destroy
Flags denoting the list to which to add the object
Description:
Adds an object to the 'fatal' and/or 'destroy' list.
At time of program termination, mrError calls the 'fatal' method
of all objects in the fatal list in reverse order in which they
were added. Afterwards, objects in the 'destroy' list are
explicitly destroyed, also in reverse order.
mrError::remove
Syntax:
obj->remove, obj
Arguments:
obj
The object to remove from the lists
Description:
Removes an object from both the 'fatal' and the 'destroy' lists.
If an object should have been registered more than once, all
entries will be removed.
mrError::mess
Syntax:
self->mess, type, 'message', origin, /exit
Arguments:
type
0 for informational message, 1 = warning, 2 = error, 3 = fatal
message
String containing the message to print
origin
Either a string or an object reference
exit
If set to '1', the program termination is started.
Description:
Private procedure!
mrError::terminateProg
Syntax:
self->terminateProg
Description:
Call fatal methods of registered objects and destroy registered
objectecs before terminating the program
mrError__define
Description:
Private Procedure (constructor)