added reportSource method

This commit is contained in:
Jack Andersen
2015-07-03 20:41:44 -10:00
parent 33f2f7b279
commit 47a7a95098
2 changed files with 110 additions and 22 deletions

View File

@@ -35,6 +35,12 @@ struct ILogger
const char* format, va_list ap)=0;
virtual void report(const char* modName, Level severity,
const wchar_t* format, va_list ap)=0;
virtual void reportSource(const char* modName, Level severity,
const char* file, unsigned linenum,
const char* format, va_list ap)=0;
virtual void reportSource(const char* modName, Level severity,
const char* file, unsigned linenum,
const wchar_t* format, va_list ap)=0;
};
/**
@@ -117,6 +123,25 @@ public:
if (severity == FatalError)
abort();
}
/**
* @brief Route new log message with source info to centralized ILogger
* @param severity Level of log report severity
* @param file Source file name from __FILE__ macro
* @param linenum Source line number from __LINE__ macro
* @param format Standard printf-style format string
*/
template <typename CharType>
inline void reportSource(Level severity, const char* file, unsigned linenum, const CharType* format, ...)
{
va_list ap;
va_start(ap, format);
for (auto& logger : MainLoggers)
logger->reportSource(m_modName, severity, file, linenum, format, ap);
va_end(ap);
if (severity == FatalError)
abort();
}
};
}