diff options
author | mattkae <mattkae@protonmail.com> | 2022-01-16 18:32:50 -0500 |
---|---|---|
committer | mattkae <mattkae@protonmail.com> | 2022-01-16 18:32:50 -0500 |
commit | 1d47e3aa120539e053ffa41293f3f756b9d07844 (patch) | |
tree | 864069813b642d7634f83b6a8843c3d23a8d4926 /themes/Logger.h | |
parent | eef48388c610bf37b07aedef03c55344d450386b (diff) |
Successful beginnings of the winter theme
Diffstat (limited to 'themes/Logger.h')
-rw-r--r-- | themes/Logger.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/themes/Logger.h b/themes/Logger.h new file mode 100644 index 0000000..7596b6f --- /dev/null +++ b/themes/Logger.h @@ -0,0 +1,43 @@ +#ifndef LOGGER_H +#define LOGGER_H + +#include <cstring> + +enum LogLevel { + LogLevel_Debug = 0, + LogLevel_Info = 1, + LogLevel_Warn = 2, + LogLevel_Error = 3 +}; + +struct LoggerOptions { + LogLevel level = LogLevel_Debug; + bool logToFile = false; + const char* filePath = "debug.log"; +}; + +namespace Logger { + void initialize(LoggerOptions options); + void setLevel(LogLevel level); + LogLevel getLevel(); + void doLog(const char* file, int lineNumber, LogLevel level, const char* format, ...); + void doDebug(const char* file, int lineNumber, const char* format, ...); + void doInfo(const char* file, int lineNumber, const char* format, ...); + void doWarning(const char* file, int lineNumber, const char* format, ...); + void doError(const char* file, int lineNumber, const char* format, ...); + void free(); +}; + +#if WIN32 +#define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) +#else +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#endif + +#define logger_log(level, format, ...) Logger::doLog(__FILENAME__, __LINE__, level, format, ## __VA_ARGS__) +#define logger_debug(format, ...) Logger::doDebug(__FILENAME__, __LINE__, format, ## __VA_ARGS__) +#define logger_info(format, ...) Logger::doInfo(__FILENAME__, __LINE__, format, ## __VA_ARGS__) +#define logger_warning(format, ...) Logger::doWarning(__FILENAME__, __LINE__, format, ## __VA_ARGS__) +#define logger_error(format, ...) Logger::doError(__FILENAME__, __LINE__, format, ## __VA_ARGS__) + +#endif |