- Clean up log level names, no need for LOG_LEVEL_ prefix when it is an

enum class.
- Clarify usage of log level in comment.
This commit is contained in:
gibbed 2019-04-30 17:40:24 -05:00
parent 179883dc0a
commit bc0ebcb26e
5 changed files with 30 additions and 29 deletions

View File

@ -69,23 +69,23 @@ void av_log_callback(void* avcl, int level, const char* fmt, va_list va) {
switch (level) {
case AV_LOG_ERROR:
level_char = '!';
log_level = xe::LogLevel::LOG_LEVEL_ERROR;
log_level = xe::LogLevel::Error;
break;
case AV_LOG_WARNING:
level_char = 'w';
log_level = xe::LogLevel::LOG_LEVEL_WARNING;
log_level = xe::LogLevel::Warning;
break;
case AV_LOG_INFO:
level_char = 'i';
log_level = xe::LogLevel::LOG_LEVEL_INFO;
log_level = xe::LogLevel::Info;
break;
case AV_LOG_VERBOSE:
level_char = 'v';
log_level = xe::LogLevel::LOG_LEVEL_DEBUG;
log_level = xe::LogLevel::Debug;
break;
case AV_LOG_DEBUG:
level_char = 'd';
log_level = xe::LogLevel::LOG_LEVEL_DEBUG;
log_level = xe::LogLevel::Debug;
break;
}

View File

@ -315,7 +315,7 @@ void LogLine(LogLevel log_level, const char prefix_char,
void FatalError(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
LogLineVarargs(LogLevel::LOG_LEVEL_ERROR, 'X', fmt, args);
LogLineVarargs(LogLevel::Error, 'X', fmt, args);
va_end(args);
#if XE_PLATFORM_WIN32

View File

@ -19,11 +19,17 @@ namespace xe {
#define XE_OPTION_ENABLE_LOGGING 1
// Log level is a general indication of the importance of a given log line.
//
// While log levels are named, they are a rough correlation of what the log line
// may be related to. These names should not be taken as fact as what a given
// log line from any log level actually is.
enum class LogLevel {
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
Error = 0,
Warning,
Info,
Debug,
Trace,
};
// Initializes the logging system and any outputs requested.
@ -56,25 +62,21 @@ void FatalError(const std::string& str);
} while (false)
#endif // ENABLE_LOGGING
#define XELOGE(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_ERROR, '!', fmt, ##__VA_ARGS__)
#define XELOGE(fmt, ...) XELOGCORE(xe::LogLevel::Error, '!', fmt, ##__VA_ARGS__)
#define XELOGW(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_WARNING, 'w', fmt, ##__VA_ARGS__)
#define XELOGI(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'i', fmt, ##__VA_ARGS__)
#define XELOGD(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_DEBUG, 'd', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::Warning, 'w', fmt, ##__VA_ARGS__)
#define XELOGI(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'i', fmt, ##__VA_ARGS__)
#define XELOGD(fmt, ...) XELOGCORE(xe::LogLevel::Debug, 'd', fmt, ##__VA_ARGS__)
#define XELOGCPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'C', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::Info, 'C', fmt, ##__VA_ARGS__)
#define XELOGAPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'A', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::Info, 'A', fmt, ##__VA_ARGS__)
#define XELOGGPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'G', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::Info, 'G', fmt, ##__VA_ARGS__)
#define XELOGKERNEL(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'K', fmt, ##__VA_ARGS__)
#define XELOGFS(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'F', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::Info, 'K', fmt, ##__VA_ARGS__)
#define XELOGFS(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'F', fmt, ##__VA_ARGS__)
} // namespace xe

View File

@ -32,13 +32,12 @@ bool trace_enabled = true;
#define THREAD_MATCH \
(!TARGET_THREAD || thread_state->thread_id() == TARGET_THREAD)
#define IFLUSH()
#define IPRINT(s) \
if (trace_enabled && THREAD_MATCH) \
xe::LogLine(xe::LogLevel::LOG_LEVEL_DEBUG, 't', s)
#define IPRINT(s) \
if (trace_enabled && THREAD_MATCH) xe::LogLine(xe::LogLevel::Debug, 't', s)
#define DFLUSH()
#define DPRINT(...) \
if (trace_enabled && THREAD_MATCH) \
xe::LogLineFormat(xe::LogLevel::LOG_LEVEL_DEBUG, 't', __VA_ARGS__)
xe::LogLineFormat(xe::LogLevel::Debug, 't', __VA_ARGS__)
uint32_t GetTracingMode() {
uint32_t mode = 0;

View File

@ -451,10 +451,10 @@ void PrintKernelCall(cpu::Export* export_entry, const Tuple& params) {
AppendKernelCallParams(string_buffer, export_entry, params);
string_buffer.Append(')');
if (export_entry->tags & xe::cpu::ExportTag::kImportant) {
xe::LogLine(xe::LogLevel::LOG_LEVEL_INFO, 'i', string_buffer.GetString(),
xe::LogLine(xe::LogLevel::Info, 'i', string_buffer.GetString(),
string_buffer.length());
} else {
xe::LogLine(xe::LogLevel::LOG_LEVEL_DEBUG, 'd', string_buffer.GetString(),
xe::LogLine(xe::LogLevel::Debug, 'd', string_buffer.GetString(),
string_buffer.length());
}
}