// Tracer.h // defines the class which does tracing #ifndef _TRACER_H #define _TRACER_H #pragma warning(disable:4786) #include #include #include // top 16 bits are for system // lower 16 bits are for user defined mask enum SDI_SystemBitType { SDI_LEVEL_NONE = 0x00000000, SDI_LEVEL_ERROR = 0x00010000, // system level SDI_LEVEL_SPECIAL = 0x00020000, SDI_LEVEL_STATE_TRANS = 0x00040000, SDI_LEVEL_SIGNIFICANT = 0x00080000, SDI_LEVEL_ENTRY_EXIT = 0x00100000, SDI_LEVEL_ARBITRARY = 0x00200000, SDI_LEVEL_DETAILED = 0x00400000, // reserved = 0x00800000, // reserved = 0x01000000, // reserved = 0x02000000, //////// reserved = 0x04000000, //////// reserved = 0x08000000, //////// reserved = 0x10000000, SDI_EVENTLOG_ALARMS = 0x20000000, SDI_SHOW_DATE = 0x40000000, // 1 = display date in output SDI_SHOW_TIME = 0x80000000, // 1 = display time in output SDI_EVENTA_DEBUG = 0x3C000000, // Debugging messages with alarm bit SDI_EVENTA_INFO = 0x38000000, // Information Messages only with alarm bit SDI_EVENTA_NOTICE = 0x34000000, // Normal but significant condition with alarm bit SDI_EVENTA_WARNING = 0x30000000, // Warning conditionwith alarm bit SDI_EVENTA_ERR = 0x2C000000, // Error with alarm bit SDI_EVENTA_CRIT = 0x28000000, // Critical Condition with alarm bit SDI_EVENTA_ALERT = 0x24000000, // Immediate action Needed with alarm bit SDI_EVENTA_EMERG = 0x20000000, // System Unusable with alarm bit SDI_EVENT_DEBUG = 0x1C000000, // Debugging messages SDI_EVENT_INFO = 0x18000000, // Information Messages only SDI_EVENT_NOTICE = 0x14000000, // Normal but significant condition SDI_EVENT_WARNING = 0x10000000, // Warning condition SDI_EVENT_ERR = 0x0C000000, // Error SDI_EVENT_CRIT = 0x08000000, // Critical Condition SDI_EVENT_ALERT = 0x04000000, // Immediate action Needed SDI_EVENT_EMERG = 0x00000000, // System Unusable SDI_EVENT_ALL = 0x1C000000, SDI_LEVEL_ALL = 0x1FFF0000 }; #define SDI_SYSTEM_MASK 0x1FFFFFFF inline SDI_SystemBitType operator|(SDI_SystemBitType lhs, SDI_SystemBitType rhs) {return (SDI_SystemBitType)((long) lhs | (long) rhs);} inline SDI_SystemBitType operator|(long lhs, SDI_SystemBitType rhs) {return (SDI_SystemBitType)((long) lhs | (long) rhs);} inline SDI_SystemBitType operator|(SDI_SystemBitType lhs, long rhs) {return (SDI_SystemBitType)((long) lhs | (long) rhs);} #define SDI_BUF_SIZE (1024) #define MAX_NAME_LENGTH 64 #define MAX_TRACE_LENGTH 256 class Tracer { private: bool bEnabled; bool bTimeStamp; bool bDateStamp; unsigned long SystemMask; char facilityName[MAX_NAME_LENGTH]; char subFacilityName[MAX_NAME_LENGTH]; typedef std::map TRACENAMEMAP; TRACENAMEMAP traceLevelName; public: Tracer(const char *FacilityName, const char *SubFacilityName, const unsigned long SystemMask); ~Tracer(); void Enable(bool); void TimeStampEnable(bool); void DateStampEnable(bool); void SetSystemMask(const unsigned long SystemMask); void SetFacilityName(const char * name); void SetSubFacilityName(const char * filename); char * GetFacilityName(); char * GetSubFacilityName(); void tracef(const unsigned long mask, const char * str_, ...); }; bool GetRegKeyBool(const HKEY Key, const char * KeyName, const char * ValueName, const bool defaultValue); long GetRegKeyLong(const HKEY Key, const char * KeyName, const char * ValueName, const long defaultValue); std::string GetRegKeyString(const HKEY Key, const char * KeyName, const char * ValueName, const char * defaultValue); long SetRegKeyBool(const HKEY Key, const char * KeyName, const char * ValueName, const bool newValue); long SetRegKeyLong(const HKEY Key, const char * KeyName, const char * ValueName, const long newValue); long SetRegKeyString(const HKEY Key, const char * KeyName, const char * ValueName, const char * newValue); #endif