diff options
Diffstat (limited to 'src/ToolBox/superpmi/superpmi-shared/logging.h')
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/logging.h | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/logging.h b/src/ToolBox/superpmi/superpmi-shared/logging.h index a2c388ee3e..dbde4af3fc 100644 --- a/src/ToolBox/superpmi/superpmi-shared/logging.h +++ b/src/ToolBox/superpmi/superpmi-shared/logging.h @@ -13,43 +13,42 @@ // General purpose logging macros // -#define LogMessage(level, ...) \ - Logger::LogPrintf(__func__, __FILE__, __LINE__, level, __VA_ARGS__) +#define LogMessage(level, ...) Logger::LogPrintf(__func__, __FILE__, __LINE__, level, __VA_ARGS__) -#define LogError(...) LogMessage(LOGLEVEL_ERROR, __VA_ARGS__) +#define LogError(...) LogMessage(LOGLEVEL_ERROR, __VA_ARGS__) #define LogWarning(...) LogMessage(LOGLEVEL_WARNING, __VA_ARGS__) #define LogMissing(...) LogMessage(LOGLEVEL_MISSING, __VA_ARGS__) -#define LogInfo(...) LogMessage(LOGLEVEL_INFO, __VA_ARGS__) +#define LogInfo(...) LogMessage(LOGLEVEL_INFO, __VA_ARGS__) #define LogVerbose(...) LogMessage(LOGLEVEL_VERBOSE, __VA_ARGS__) -#define LogDebug(...) LogMessage(LOGLEVEL_DEBUG, __VA_ARGS__) +#define LogDebug(...) LogMessage(LOGLEVEL_DEBUG, __VA_ARGS__) -#define LogIssue(issue, msg, ...) \ - IssueLogger::LogIssueHelper(__FUNCTION__, __FILE__, __LINE__, issue, msg, __VA_ARGS__) +#define LogIssue(issue, msg, ...) IssueLogger::LogIssueHelper(__FUNCTION__, __FILE__, __LINE__, issue, msg, __VA_ARGS__) // Captures the exception message before throwing so we can log it at the point of occurrence -#define LogException(exCode, msg, ...) \ - do { \ - Logger::LogExceptionMessage(__FUNCTION__, __FILE__, __LINE__, exCode, msg, __VA_ARGS__); \ - ThrowException(exCode, msg, __VA_ARGS__); \ +#define LogException(exCode, msg, ...) \ + do \ + { \ + Logger::LogExceptionMessage(__FUNCTION__, __FILE__, __LINE__, exCode, msg, __VA_ARGS__); \ + ThrowException(exCode, msg, __VA_ARGS__); \ } while (0) // These are specified as flags so subsets of the logging functionality can be enabled/disabled at once enum LogLevel : UINT32 { - LOGLEVEL_ERROR = 0x00000001, // Internal fatal errors that are non-recoverable - LOGLEVEL_WARNING = 0x00000002, // Internal conditions that are unusual, but not serious - LOGLEVEL_MISSING = 0x00000004, // Failures to due to missing JIT-EE details - LOGLEVEL_ISSUE = 0x00000008, // Issues found with the JIT, e.g. asm diffs, asserts - LOGLEVEL_INFO = 0x00000010, // Notifications/summaries, e.g. 'Loaded 5 Jitted 4 FailedCompile 1' - LOGLEVEL_VERBOSE = 0x00000020, // Status messages, e.g. 'Jit startup took 151.12ms' - LOGLEVEL_DEBUG = 0x00000040 // Detailed output that's only useful for SuperPMI debugging + LOGLEVEL_ERROR = 0x00000001, // Internal fatal errors that are non-recoverable + LOGLEVEL_WARNING = 0x00000002, // Internal conditions that are unusual, but not serious + LOGLEVEL_MISSING = 0x00000004, // Failures to due to missing JIT-EE details + LOGLEVEL_ISSUE = 0x00000008, // Issues found with the JIT, e.g. asm diffs, asserts + LOGLEVEL_INFO = 0x00000010, // Notifications/summaries, e.g. 'Loaded 5 Jitted 4 FailedCompile 1' + LOGLEVEL_VERBOSE = 0x00000020, // Status messages, e.g. 'Jit startup took 151.12ms' + LOGLEVEL_DEBUG = 0x00000040 // Detailed output that's only useful for SuperPMI debugging }; // Preset log level combinations enum LogLevelMask : UINT32 { LOGMASK_NONE = 0x00000000, - LOGMASK_DEFAULT = (LOGLEVEL_DEBUG - 1), // Default is essentially "enable everything except debug" + LOGMASK_DEFAULT = (LOGLEVEL_DEBUG - 1), // Default is essentially "enable everything except debug" LOGMASK_ALL = 0xffffffff }; @@ -59,32 +58,40 @@ enum LogLevelMask : UINT32 class Logger { private: - static bool s_initialized; - static UINT32 s_logLevel; - static HANDLE s_logFile; - static char *s_logFilePath; + static bool s_initialized; + static UINT32 s_logLevel; + static HANDLE s_logFile; + static char* s_logFilePath; static CRITICAL_SECTION s_critSec; public: static void Initialize(); static void Shutdown(); - static void OpenLogFile(char *logFilePath); + static void OpenLogFile(char* logFilePath); static void CloseLogFile(); - static UINT32 ParseLogLevelString(const char *specifierStr); - static void SetLogLevel(UINT32 logLevelMask) { s_logLevel = logLevelMask; } - static UINT32 GetLogLevel() { return s_logLevel; } + static UINT32 ParseLogLevelString(const char* specifierStr); + static void SetLogLevel(UINT32 logLevelMask) + { + s_logLevel = logLevelMask; + } + static UINT32 GetLogLevel() + { + return s_logLevel; + } // Return true if all specified log levels are enabled. - static bool IsLogLevelEnabled(UINT32 logLevelMask) { return (logLevelMask & GetLogLevel()) == logLevelMask; } - - static void LogPrintf(const char *function, const char *file, int line, - LogLevel level, const char *msg, ...); - static void LogVprintf(const char *function, const char *file, int line, - LogLevel level, va_list argList, const char *msg); - static void LogExceptionMessage(const char *function, const char *file, int line, - DWORD exceptionCode, const char *msg, ...); + static bool IsLogLevelEnabled(UINT32 logLevelMask) + { + return (logLevelMask & GetLogLevel()) == logLevelMask; + } + + static void LogPrintf(const char* function, const char* file, int line, LogLevel level, const char* msg, ...); + static void LogVprintf( + const char* function, const char* file, int line, LogLevel level, va_list argList, const char* msg); + static void LogExceptionMessage( + const char* function, const char* file, int line, DWORD exceptionCode, const char* msg, ...); }; enum IssueType @@ -101,8 +108,7 @@ enum IssueType class IssueLogger { public: - static void LogIssueHelper(const char *function, const char *file, int line, - IssueType issue, const char *msg, ...); + static void LogIssueHelper(const char* function, const char* file, int line, IssueType issue, const char* msg, ...); }; #endif |