📄 warlogeventhandler.h
字号:
/** Log event handler. Must be overloaded When an event is sent to the log handler, its type is checked with the event-handlers mask (mMask), and if the type/flag is not set in the mask, the event/handler silently ignores the log-event. You can set the mask with the \Ref{SetEventMask} member function. Some event-handlers also use mFlags to determine how verbose the log/message should be written. The built-in handlers for stdout and stderr use this flag-field. */#ifndef WAR_LOG_EVENT_HANDLER_H#define WAR_LOG_EVENT_HANDLER_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_TYPES_H# include "WarTypes.h"#endif#ifndef WAR_SMART_POINTER_H# include "WarSmartPointer.h"#endif#ifndef WAR_LOG_EVENT_H# include "WarLogEvent.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarLogT;class WarLogEngine;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarLogEventHandler : public WarSmartPointer{public: /// Flags to supress log-information enum HandlerFlagsE { SHOW_ALL = 0, /// SUPRESS_PREFIX = 0x0001, /// SUPRESS_MODULE = 0x0002, /// SUPRESS_TYPE = 0x0004, /// SUPRESS_DATE = 0x0008, /// SUPRESS_ERROR = 0x0010, /// SUPRESS_IDENTIFIER = 0x0020 }; // LIFECYCLE /** * Default constructor. */ WarLogEventHandler(war_ccstr_t name) : mName(name), mFlags(0), mMask(0) { // Set default event mask SetEventMask(GetDefaultEventMask()); } /** * Copy constructor. * * @param from The value to copy to this object. */ WarLogEventHandler(const WarLogEventHandler& from); // OPERATORS /** * Assignment operator. * * @param from THe value to assign to this object. * * @return A reference to this object. */ WarLogEventHandler& operator=(WarLogEventHandler& from); // OPERATIONS bool operator == (war_ccstr_t name) { return stricmp(mName.c_str(), name) == 0; } /// Set the supress flags void SetSupressFlags(war_uint32_t flag) { mFlags = flag; } /// Set the event mask void SetEventMask(war_uint32_t mask) { mMask = mask; } // ACCESS // INQUIRY war_ccstr_t GetName() const { return mName.c_str(); } /// Get the current supress flags war_uint32_t GetSupressFlags() { return mFlags; } /// Ret the current event mask war_uint32_t GetEventMask() { return mMask; } // Override to change the default mask virtual war_uint32_t GetDefaultEventMask() { war_uint32_t mask = 0; WARLOG_SET(mask, WARLOG_ERROR, 1); WARLOG_SET(mask, WARLOG_INOUT, 1); WARLOG_SET(mask, WARLOG_SECURITY, 1); WARLOG_SET(mask, WARLOG_WARNINGS, 1); WARLOG_SET(mask, WARLOG_SYSTEM, 1); WARLOG_SET(mask, WARLOG_SNDFILE, 1); WARLOG_SET(mask, WARLOG_RCVFILE, 1); WARLOG_SET(mask, WARLOG_CREDIR, 1); WARLOG_SET(mask, WARLOG_DELDIR, 1); WARLOG_SET(mask, WARLOG_DELFILE, 1); WARLOG_SET(mask, WARLOG_LOGIN, 1); WARLOG_SET(mask, WARLOG_LOGOUT, 1); WARLOG_SET(mask, WARLOG_CREACC, 1); WARLOG_SET(mask, WARLOG_DELACC, 1); WARLOG_SET(mask, WARLOG_CHGACC, 1); WARLOG_SET(mask, WARLOG_INFO, 1); WARLOG_SET(mask, WARLOG_NETWORK, 1); return mask; }protected:private: friend class WarLogEngine; /** Overload to do actual logging * Note: This function _must_ return instantly. * If the logging may take some time, the * event must be queued and the control returned * to the calling function! * * This function is guaranteed to not be * called reentrantly. */ virtual void OnEvent(WarLogEvent& rEvent) = 0; /// Unique Handler name const std::string mName; /// Supress flags war_uint32_t mFlags; /// Log event mask war_uint32_t mMask;};/* INLINE METHODS *//* EXTERNAL REFERENCES */typedef WarPtrWrapper<WarLogEventHandler> war_logeventhandler_ptr_t;#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* _WAR_LOG_EVENT_HANDLER_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -