Matrix Science header
Public Types | Public Member Functions | Static Public Member Functions

ms_loggingmonitor Class Reference
[Error handling and logging]

Monitor class to delegate logging events generated from multiple sources. More...

#include <ms_logging.hpp>

Collaboration diagram for ms_loggingmonitor:
Collaboration graph
[legend]

List of all members.

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_loggergetLogEventsHandler (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.

Detailed Description

Monitor class to delegate logging events generated from multiple sources.

See Logging using ms_loggingmonitor for details.


Member Enumeration Documentation

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#.

Enumerator:
LVL_NONE 

Logging disabled.

LVL_ERROR 

A fatal error that results in the object being 'invalid'.

LVL_WARNING 

A warning message.

LVL_INFO 

Information message. Not available by default unless setLoggingMask() called.

LVL_DEBUG1 

Debug level 1 message. Not available by default unless setLoggingMask() called .

LVL_DEBUG2 

Debug level 2 message. Not available by default unless setLoggingMask() called.

LVL_DEBUG3 

Debug level 3 message. Not available by default unless setLoggingMask() called.

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()


Member Function Documentation

int addLogEventsHandler ( ms_logger logger ) [virtual]

Registers the passed ms_logger with the ms_loggingmonitor.

See also:
Maintaining object references: two rules of thumb
Parameters:
loggeris the ms_logger object to add
Returns:
the uid of the logger object in the ms_loggingmonitor, or -1 if it is already registered
ms_loggingmonitor & getDefaultMonitor (  ) [static]

Returns the global ms_loggingmonitor used by msparser.

To add a custom ms_logger to the default ms_logging monitor, call getDefaultMonitor().addLogEventsHandler()

Returns:
the global ms_loggingmonitor object used to handle all logging events from msparser
ms_logger * getLogEventsHandler ( const int  uid ) [virtual]

Returns the ms_logger object associated with the passed uid, or null if the specified uid is invalid.

Parameters:
uidthe uid of the ms_logger to retrieve
Returns:
the ms_logger associated with the passed uid or NULL if not found
long getLogMask ( unsigned  source = SRC_ALL ) [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

Parameters:
sourceshould be one of the Source_e values. See setLogMask for details.
Returns:
the current logging events mask.
int getNumLogEventsHandlers (  ) const [virtual]

Returns the number of events handlers.

Returns:
will be zero if there are no handlers, so there is no point in sending any messages to the logging monitor
std::string messageSourceAsText ( Source_e  eSource ) [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:

  • SRC_APPLICATION : "APPLICATION_"
  • SRC_MASCOTSERVER : "MASCOTSERVER"
  • SRC_MSPARSER : "MSPARSER_API"
  • SRC_MDRO : "MDRO_LIB_API"
  • SRC_MSQUANTLIB : "QUANTLIB_API"
  • SRC_PURIFIERAPI : "PURIFIER_API"
  • SRC_PURIFIERAPP : "PURIFIER_APP"
  • SRC_DENOVOLIB : "MSDENOVO_API"
  • SRC_VENDORSTART : "VENDOR_START"
  • SRC_ALL : "ALL_SOURCES_"
  • Any other number : "UNKNOWN_SRC_"
Parameters:
eSourceshould be on of the ms_loggingmonitor::Source_e enum values
Returns:
One of 12 character strings above.
bool removeLogEventsHandler ( const int  uid ) [virtual]

Deregisters the specified ms_logger from the ms_loggingmonitor.

Parameters:
uidthe uid of the ms_logger to removed
Returns:
true if the specified ms_logger was removed, false if it was not found
void setDefaultMonitor ( ms_loggingmonitor loggingMonitor ) [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()

Parameters:
loggingMonitorthe ms_loggingmonitor to use
void setLogMask ( long  newVal,
unsigned  source = SRC_ALL 
) [virtual]

Sets the current logging events mask.

Parameters:
newValthe new log mask value to set. Bitwise Or the relevant ms_loggingmonitor::Level_e values
sourceshould 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.
std::string severityAsText ( Level_e  eSeverity ) [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:

  • LVL_ERROR : "LVL_ERROR "
  • LVL_WARNING : "LVL_WARNING"
  • LVL_INFO : "LVL_INFO "
  • LVL_DEBUG1 : "LVL_DEBUG1 "
  • LVL_DEBUG2 : "LVL_DEBUG2 "
  • LVL_DEBUG3 : "LVL_DEBUG3 "
  • Unrecognised : "LVL_UNKNOWN"
Parameters:
eSeverityshould be on of the ms_loggingmonitor::Level_e enum values
Returns:
One of 11 character strings above.

The documentation for this class was generated from the following files:

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:33