ivutils
|
Logger class to control (computational) function behaviour when something requiring user attention has happened. More...
#include <logexc.h>
Public Member Functions | |
int | set_global (bool set) |
sets/unsets this logger as the global logger | |
virtual void | extra_levels (int out_level=vblALLBAD|vblMESS1, int stop_level=vblFATAL) |
nonzero extra levels are applied instead of set ones | |
virtual | ~message_logger () |
checks that the deleted one is not in global logger chain | |
Static Public Member Functions | |
static message_logger & | global () |
returns a reference to global logger if not set, links with default message_logger | |
Protected Attributes | |
message_logger * | prev |
used to restore the previous global logger | |
Logger class to control (computational) function behaviour when something requiring user attention has happened.
message(signal,errcode, text) is used to either throw an exception or return errorcode At first, the the level of error is determined via log_exception_traits<>::level(signal) For integer (enum) signals the level is the signal itself. Then text is printed, if signal level is listed in output levels or (or in extra outlevels, if they are set) via log_text() function. If level has vblERR bit, the behaviour is controlled by the flag specified in set_throw(flag): flag=0: nothing done; flag=1: calls add_words() for signal and throws signal; flag=2: throws pair<>(errcode, text); flag=3: throws errcode. Then, if the level is listed in stop_levels (or in extra stop levels, if they are set), the program is aborted, otherwise errcode is returned; The function set_levels(out_levels,stop_levels) is used to specify bitflags for the levels which require message output or/and program termination. Stop level has effect only when exceptions are not thrown. The function extra_levels(eout_levels,estop_levels) is used to temporarily set the corresponding levels, they are unset (the original levels are restored) by calling extra_levels(0,0).