Monitor class to delegate logging events generated from multiple sources. More...
#include <ms_logging.hpp>
Public Types | |
enum | Level_e { LVL_NONE = 0 , LVL_ERROR = 1 , LVL_WARNING = 2 , LVL_INFO = 4 , LVL_DEBUG1 = 8 , LVL_DEBUG2 = 16 , LVL_DEBUG3 = 32 } |
Logging severity levels. More... | |
enum | Source_e { SRC_APPLICATION = 1 , SRC_MASCOTSERVER = 2 , SRC_MSPARSER = 3 , SRC_MDRO = 4 , SRC_MSQUANTLIB = 5 , SRC_PURIFIERAPI = 6 , SRC_PURIFIERAPP = 7 , SRC_DENOVOLIB = 8 , SRC_VENDORSTART = 100 , SRC_ALL = 0xFFFF } |
Logging event source. More... | |
Public Member Functions | |
ms_loggingmonitor () | |
Constructor. | |
virtual | ~ms_loggingmonitor () |
Destructor. | |
virtual int | addLogEventsHandler (ms_logger &logger) |
Registers the passed ms_logger with the ms_loggingmonitor. | |
virtual ms_logger * | getLogEventsHandler (const int uid) |
Returns the ms_logger object associated with the passed uid, or null if the specified uid is invalid. | |
virtual long | getLogMask (unsigned source=SRC_ALL) |
Returns the current logging events mask. | |
virtual int | getNumLogEventsHandlers () const |
Returns the number of events handlers. | |
virtual void | logMessage (Level_e eSeverity, Source_e eSource, long lMsgId, const std::string &text, const char *srcFileName, const int srcFileLineNum, long lContextId=0) const |
Logs the passed message with all registered ms_logger objects. | |
virtual bool | removeLogEventsHandler (const int uid) |
Deregisters the specified ms_logger from the ms_loggingmonitor. | |
virtual void | setLogMask (long newVal, unsigned source=SRC_ALL) |
Sets the current logging events mask. | |
Static Public Member Functions | |
static matrix_science::ms_loggingmonitor & | getDefaultMonitor () |
Returns the global ms_loggingmonitor used by msparser. | |
static std::string | messageSourceAsText (Source_e eSource) |
Returns a Source_e enum value as a text string. | |
static void | setDefaultMonitor (ms_loggingmonitor &loggingMonitor) |
Sets the global ms_loggingmonitor to be used by msparser. | |
static std::string | severityAsText (Level_e eSeverity) |
Returns a severity enum value as a text string. | |
Monitor class to delegate logging events generated from multiple sources.
See Logging using ms_loggingmonitor for details.
enum Level_e |
Logging severity levels.
These have the same meaning as ms_errs::msg_sev, but do not have the same values. See Using enumerated values and static const ints in Perl, Java, Python and C#.
enum Source_e |
Logging event source.
See Using enumerated values and static const ints in Perl, Java, Python and C#.
Enumerator | |
---|---|
SRC_APPLICATION | Logging event raised by the current application. |
SRC_MASCOTSERVER | Logging event raised by Mascot server. |
SRC_MSPARSER | Logging event raised by the msparser library. |
SRC_MDRO | Logging event raised by the MDRO library. |
SRC_MSQUANTLIB | Logging event raised by the msquantlib library. |
SRC_PURIFIERAPI | Logging event raised by the purifierapi library. |
SRC_PURIFIERAPP | Logging event raised by the Purifier application. |
SRC_DENOVOLIB | Logging event raised by the Denovo library. |
SRC_VENDORSTART | Use this value for third party applications. |
SRC_ALL | Use this with setLogMask() and getLogMask() |
|
virtual |
Registers the passed ms_logger with the ms_loggingmonitor.
logger | is the ms_logger object to add |
|
static |
Returns the global ms_loggingmonitor used by msparser.
To add a custom ms_logger to the default ms_logging monitor, call getDefaultMonitor().addLogEventsHandler()
|
virtual |
|
virtual |
Returns the current logging events mask.
The default log mask value is Level_e::LVL_ERROR | Level_e::LVL_WARNING, so only messages with a severity level of Level_e::LVL_ERROR or Level_e::LVL_WARNING will be logged
source | should be one of the Source_e values. See setLogMask for details. |
|
virtual |
Returns the number of events handlers.
|
static |
Returns a Source_e enum value as a text string.
Useful for writing a human readable log file, this method returns the message source as text:
eSource | should be on of the ms_loggingmonitor::Source_e enum values |
|
virtual |
Deregisters the specified ms_logger from the ms_loggingmonitor.
uid | the uid of the ms_logger to removed |
|
static |
Sets the global ms_loggingmonitor to be used by msparser.
It is normally sufficient to add ms_logger objects to the default ms_loggingmonitor using getDefaultMonitor()
loggingMonitor | the ms_loggingmonitor to use |
|
virtual |
Sets the current logging events mask.
newVal | the new log mask value to set. Bitwise Or the relevant ms_loggingmonitor::Level_e values |
source | should be one of the Source_e values. For most applications, the same mask (logging level) can be used for all the components, so the default of SRC_ALL can be used. If different levels are required, then call this function multiple times, firstly with SRC_ALL to set the default, and then with, for example SRC_MDRO to set a higher or lower level for MDRO logging. When called with SRC_ALL, all previous values for specific components are removed. |
|
static |
Returns a severity enum value as a text string.
Useful for writing a human readable log file, this method returns the message severity as text:
eSeverity | should be on of the ms_loggingmonitor::Level_e enum values |