diff --git a/src/logging/Logger.cpp b/src/logging/Logger.cpp index 2a675a2..12ee1aa 100644 --- a/src/logging/Logger.cpp +++ b/src/logging/Logger.cpp @@ -15,13 +15,13 @@ namespace Feather::Logging // Since min and max are inclusive we have to add 1 here // This assumes max > min (they better be) - static constexpr int NUM_LEVELS = ((int)Level::MAX_LEVEL - (int)Level::MIN_LEVEL) + 1; + static constexpr int NUM_LEVELS = ((int)Level::MaxLevel - (int)Level::MinLevel) + 1; // Temporary solution while we don't have named enums static const char *s_levelNames[NUM_LEVELS] = {"ERROR", "WARNING", "INFO", "DEBUG", "TRACE"}; // Shifts an enum value to be a positive index in s_levelNames - static constexpr int LEVEL_NAME_OFFSET = 0 - (int)Level::MIN_LEVEL; + static constexpr int LEVEL_NAME_OFFSET = 0 - (int)Level::MinLevel; Logger::Logger() @@ -38,16 +38,16 @@ namespace Feather::Logging // ESC (\x1B) CSI ([) SGR (m) switch (level) { - case Level::WARNING: + case Level::Warning: // 1 BRIGHT, 33 YELLOW offset += snprintf(buffer + offset, MAX_LOG_MESSAGE_LENGTH - offset, "\x1B[1;33m"); break; - case Level::ERROR: + case Level::Error: // 1 BRIGHT, 31 RED offset += snprintf(buffer + offset, MAX_LOG_MESSAGE_LENGTH - offset, "\x1B[1;31m"); break; default: - case Level::INFO: + case Level::Info: break; } @@ -74,7 +74,7 @@ namespace Feather::Logging // Append ANSI style reset code 0 and newline offset += snprintf(buffer + offset, MAX_LOG_MESSAGE_LENGTH - offset, "\x1b[0m\n"); - if (level >= Level::INFO) { + if (level >= Level::Info) { // Info and above go to stdout printf(buffer); } else { @@ -86,7 +86,7 @@ namespace Feather::Logging ChannelID Logger::RegisterChannel(const char* name) { if (m_channelCount >= MAX_LOGGING_CHANNEL_COUNT) { - Log_Msg( LOG_LOGGING, ERROR, "Cannot register new logging channel '%s' because the maximum of %d channels has been exceeded.", name, MAX_LOGGING_CHANNEL_COUNT ); + Log_Msg( LOG_LOGGING, Error, "Cannot register new logging channel '%s' because the maximum of %d channels has been exceeded.", name, MAX_LOGGING_CHANNEL_COUNT ); return LOG_GENERAL; } Channel *channel = new Channel(name); diff --git a/src/logging/Logger.h b/src/logging/Logger.h index 08b363c..1d2b40c 100644 --- a/src/logging/Logger.h +++ b/src/logging/Logger.h @@ -10,23 +10,23 @@ namespace Feather::Logging enum class Level { // Serious problems - ERROR = -2, + Error = -2, // Potential problems of note - WARNING = -1, + Warning = -1, // General messages for end-users - INFO = 0, + Info = 0, // More advanced information for problem-solving - DEBUG = 1, + Debug = 1, // Fine grained spew - TRACE = 2, + Trace = 2, // These are an inclusve interval - MIN_LEVEL = ERROR, - MAX_LEVEL = TRACE, + MinLevel = Error, + MaxLevel = Trace, }; /*==== Channels ==============================*/ @@ -62,22 +62,22 @@ namespace Feather::Logging extern Logger GlobalLogger; } -#define REGISTER_LOGGING_CHANNEL(Name) Feather::Logging::GlobalLogger.RegisterChannel(Name); +#define REGISTER_LOGGING_CHANNEL(Name) ::Feather::Logging::GlobalLogger.RegisterChannel(Name); // Logs a message, specifying a channel and log level -#define Log_Msg(_Channel, _Level, _Message, ...) Feather::Logging::GlobalLogger.LogDirect(Feather::Logging::_Channel, Feather::Logging::Level::_Level, _Message, ##__VA_ARGS__) +#define Log_Msg(_Channel, _Level, _Message, ...) ::Feather::Logging::GlobalLogger.LogDirect(::Feather::Logging::_Channel, ::Feather::Logging::Level::_Level, _Message, ##__VA_ARGS__) // Logs a general message for end-users -#define Log_Info(Message, ...) Log_Msg(LOG_GENERAL, INFO, Message, ##__VA_ARGS__) +#define Log_Info(Message, ...) Log_Msg(LOG_GENERAL, Info, Message, ##__VA_ARGS__) // Logs a potential problem of note -#define Log_Warn(Message, ...) Log_Msg(LOG_GENERAL, WARNING, Message, ##__VA_ARGS__) +#define Log_Warn(Message, ...) Log_Msg(LOG_GENERAL, Warning, Message, ##__VA_ARGS__) // Logs a serious problem -#define Log_Error(Message, ...) Log_Msg(LOG_GENERAL, ERROR, Message, ##__VA_ARGS__) +#define Log_Error(Message, ...) Log_Msg(LOG_GENERAL, Error, Message, ##__VA_ARGS__) // Logs debug information for developers -#define Log_Debug(Message, ...) Log_Msg(LOG_GENERAL, DEBUG, Message, ##__VA_ARGS__) +#define Log_Debug(Message, ...) Log_Msg(LOG_GENERAL, Debug, Message, ##__VA_ARGS__) // Logs fine grained debug information -#define Log_Trace(Message, ...) Log_Msg(LOG_GENERAL, TRACE, Message, ##__VA_ARGS__) +#define Log_Trace(Message, ...) Log_Msg(LOG_GENERAL, Trace, Message, ##__VA_ARGS__)