Matrix Science header

ms_logging.hpp

00001 /*
00002 ##############################################################################
00003 # File: ms_logging.hpp                                                       #
00004 # Mascot Parser toolkit                                                      #
00005 # Encapsulates general purpose objects which act as conduits for receiving   #
00006 # and processing logging events                                              #
00007 ##############################################################################
00008 # COPYRIGHT NOTICE                                                           #
00009 # Copyright 2015-2016 Matrix Science Limited  All Rights Reserved.           #
00010 #                                                                            #
00011 ##############################################################################
00012 #    $Source: /vol/cvsroot/parser/inc/ms_logging.hpp,v $
00013 #    $Author: davidc $ 
00014 #      $Date: 2017/04/18 16:39:42 $ 
00015 #  $Revision: 1.5 $
00016 ##############################################################################
00017 */
00018 
00019 #ifndef MS_LOGGING_HPP
00020 #define MS_LOGGING_HPP
00021 
00022 #ifdef _WIN32
00023 #pragma warning(disable:4251)   // Don't want all classes to be exported
00024 #pragma warning(disable:4786)   // Debug symbols too long
00025 #   ifndef _MATRIX_USE_STATIC_LIB
00026 #       ifdef MS_MASCOTRESFILE_EXPORTS
00027 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00028 #       else
00029 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00030 #       endif
00031 #   else
00032 #       define MS_MASCOTRESFILE_API
00033 #   endif
00034 #else
00035 #   define MS_MASCOTRESFILE_API
00036 #endif
00037 
00038 // Includes from the standard template library
00039 #include <string>
00040 
00041 namespace msparser_internal {
00042     class ms_loggingmonitor_impl;
00043 }
00044 
00045 namespace matrix_science {
00046     class ms_logger;        
00047     
00052 
00053     class MS_MASCOTRESFILE_API ms_loggingmonitor 
00054     {
00055     public:
00057 
00061         enum Level_e {
00062             LVL_ERROR    = 1,   
00063             LVL_WARNING  = 2,   
00064             LVL_INFO     = 4,   
00065             LVL_DEBUG1   = 8,   
00066             LVL_DEBUG2   = 16,  
00067             LVL_DEBUG3   = 32   
00068         }; // enum LogLevel_e
00069 
00071 
00074         enum Source_e {
00075             SRC_APPLICATION  = 1,    
00076             SRC_MASCOTSERVER = 2,    
00077             SRC_MSPARSER     = 3,    
00078             SRC_MDRO         = 4,    
00079             SRC_MSQUANTLIB   = 5,    
00080             SRC_PURIFIERAPI  = 6,    
00081             SRC_PURIFIERAPP  = 7,    
00082             SRC_DENOVOLIB    = 8,    
00083             SRC_VENDORSTART  = 100   
00084         }; // enum LogSource_e
00085 
00086     private:        
00087         msparser_internal::ms_loggingmonitor_impl *pImpl_;
00088         static ms_loggingmonitor defaultLoggingMonitor;
00089 
00090     public:
00092         ms_loggingmonitor();
00093 
00095         virtual ~ms_loggingmonitor();
00096 
00098         virtual int addLogEventsHandler(ms_logger& logger);
00099 
00101         virtual bool removeLogEventsHandler(const int uid);
00102 
00104         virtual ms_logger * getLogEventsHandler(const int uid);
00105 
00107         virtual void logMessage(Level_e eSeverity,
00108             Source_e eSource,
00109             long lMsgId,
00110             const std::string & text,
00111             long lContextId=0) const;
00112 
00114         virtual long getLogMask();
00115 
00117         virtual void setLogMask(long newVal);
00118 
00120         static matrix_science::ms_loggingmonitor & getDefaultMonitor();
00122         static void setDefaultMonitor(ms_loggingmonitor & loggingMonitor);
00123 
00125         static std::string messageSourceAsText(Source_e eSource);
00126 
00128         static std::string severityAsText(Level_e eSeverity);
00129 
00130     }; // class ms_loggingmonitor
00131 
00133     class MS_MASCOTRESFILE_API ms_logger {
00134     public:
00136         virtual ~ms_logger() {}
00138         virtual void onLogMessage(ms_loggingmonitor::Level_e eSeverity,
00139             ms_loggingmonitor::Source_e eSource,
00140             long lMsgId,
00141             const std::string & text,
00142             long lContextId=0)=0;
00143     }; // class ms_logger
00144 
00146     class MS_MASCOTRESFILE_API ms_stdout_logger : public ms_logger {
00147     public:
00149         ms_stdout_logger();
00151         virtual ~ms_stdout_logger();
00152 
00154         virtual void onLogMessage(ms_loggingmonitor::Level_e eSeverity,
00155             ms_loggingmonitor::Source_e eSource,
00156             long lMsgId,
00157             const std::string & text,
00158             long lContextId=0);
00159 
00160     }; // class ms_stdout_logger
00161 
00163     class MS_MASCOTRESFILE_API ms_file_logger : public ms_logger {
00164     public:
00166         ms_file_logger();
00168         ms_file_logger(const std::string logFileName);
00170         virtual ~ms_file_logger();
00172         std::string getLogFilename();
00174         void setLogFilename(std::string logFileName);
00176         virtual void onLogMessage(ms_loggingmonitor::Level_e eSeverity,
00177             ms_loggingmonitor::Source_e eSource,
00178             long lMsgId,
00179             const std::string & text,
00180             long lContextId=0);
00181 
00182     private:
00183         std::string logfilename_;
00184 
00185     }; // class ms_file_logger
00186  // end of error_handling_group
00188 } // namespace matrix_science
00189 
00190 #endif // MS_LOGGING_HPP
00191 
00192 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51