- 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) { switch (level) {
case AV_LOG_ERROR: case AV_LOG_ERROR:
level_char = '!'; level_char = '!';
log_level = xe::LogLevel::LOG_LEVEL_ERROR; log_level = xe::LogLevel::Error;
break; break;
case AV_LOG_WARNING: case AV_LOG_WARNING:
level_char = 'w'; level_char = 'w';
log_level = xe::LogLevel::LOG_LEVEL_WARNING; log_level = xe::LogLevel::Warning;
break; break;
case AV_LOG_INFO: case AV_LOG_INFO:
level_char = 'i'; level_char = 'i';
log_level = xe::LogLevel::LOG_LEVEL_INFO; log_level = xe::LogLevel::Info;
break; break;
case AV_LOG_VERBOSE: case AV_LOG_VERBOSE:
level_char = 'v'; level_char = 'v';
log_level = xe::LogLevel::LOG_LEVEL_DEBUG; log_level = xe::LogLevel::Debug;
break; break;
case AV_LOG_DEBUG: case AV_LOG_DEBUG:
level_char = 'd'; level_char = 'd';
log_level = xe::LogLevel::LOG_LEVEL_DEBUG; log_level = xe::LogLevel::Debug;
break; break;
} }

View File

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

View File

@ -19,11 +19,17 @@ namespace xe {
#define XE_OPTION_ENABLE_LOGGING 1 #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 { enum class LogLevel {
LOG_LEVEL_ERROR, Error = 0,
LOG_LEVEL_WARNING, Warning,
LOG_LEVEL_INFO, Info,
LOG_LEVEL_DEBUG, Debug,
Trace,
}; };
// Initializes the logging system and any outputs requested. // Initializes the logging system and any outputs requested.
@ -56,25 +62,21 @@ void FatalError(const std::string& str);
} while (false) } while (false)
#endif // ENABLE_LOGGING #endif // ENABLE_LOGGING
#define XELOGE(fmt, ...) \ #define XELOGE(fmt, ...) XELOGCORE(xe::LogLevel::Error, '!', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::LOG_LEVEL_ERROR, '!', fmt, ##__VA_ARGS__)
#define XELOGW(fmt, ...) \ #define XELOGW(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_WARNING, 'w', fmt, ##__VA_ARGS__) XELOGCORE(xe::LogLevel::Warning, 'w', fmt, ##__VA_ARGS__)
#define XELOGI(fmt, ...) \ #define XELOGI(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'i', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'i', fmt, ##__VA_ARGS__) #define XELOGD(fmt, ...) XELOGCORE(xe::LogLevel::Debug, 'd', fmt, ##__VA_ARGS__)
#define XELOGD(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_DEBUG, 'd', fmt, ##__VA_ARGS__)
#define XELOGCPU(fmt, ...) \ #define XELOGCPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'C', fmt, ##__VA_ARGS__) XELOGCORE(xe::LogLevel::Info, 'C', fmt, ##__VA_ARGS__)
#define XELOGAPU(fmt, ...) \ #define XELOGAPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'A', fmt, ##__VA_ARGS__) XELOGCORE(xe::LogLevel::Info, 'A', fmt, ##__VA_ARGS__)
#define XELOGGPU(fmt, ...) \ #define XELOGGPU(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'G', fmt, ##__VA_ARGS__) XELOGCORE(xe::LogLevel::Info, 'G', fmt, ##__VA_ARGS__)
#define XELOGKERNEL(fmt, ...) \ #define XELOGKERNEL(fmt, ...) \
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'K', fmt, ##__VA_ARGS__) XELOGCORE(xe::LogLevel::Info, 'K', fmt, ##__VA_ARGS__)
#define XELOGFS(fmt, ...) \ #define XELOGFS(fmt, ...) XELOGCORE(xe::LogLevel::Info, 'F', fmt, ##__VA_ARGS__)
XELOGCORE(xe::LogLevel::LOG_LEVEL_INFO, 'F', fmt, ##__VA_ARGS__)
} // namespace xe } // namespace xe

View File

@ -33,12 +33,11 @@ bool trace_enabled = true;
(!TARGET_THREAD || thread_state->thread_id() == TARGET_THREAD) (!TARGET_THREAD || thread_state->thread_id() == TARGET_THREAD)
#define IFLUSH() #define IFLUSH()
#define IPRINT(s) \ #define IPRINT(s) \
if (trace_enabled && THREAD_MATCH) \ if (trace_enabled && THREAD_MATCH) xe::LogLine(xe::LogLevel::Debug, 't', s)
xe::LogLine(xe::LogLevel::LOG_LEVEL_DEBUG, 't', s)
#define DFLUSH() #define DFLUSH()
#define DPRINT(...) \ #define DPRINT(...) \
if (trace_enabled && THREAD_MATCH) \ 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 GetTracingMode() {
uint32_t mode = 0; 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); AppendKernelCallParams(string_buffer, export_entry, params);
string_buffer.Append(')'); string_buffer.Append(')');
if (export_entry->tags & xe::cpu::ExportTag::kImportant) { 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()); string_buffer.length());
} else { } else {
xe::LogLine(xe::LogLevel::LOG_LEVEL_DEBUG, 'd', string_buffer.GetString(), xe::LogLine(xe::LogLevel::Debug, 'd', string_buffer.GetString(),
string_buffer.length()); string_buffer.length());
} }
} }