diff --git a/include/Spectre/System/Log.h b/include/Spectre/System/Log.h index b10bf94..26d2ac1 100644 --- a/include/Spectre/System/Log.h +++ b/include/Spectre/System/Log.h @@ -15,6 +15,7 @@ public : T_WARNING = 1 << 0, T_CRITICAL = 1 << 1, T_ERROR = 1 << 2, + T_DEBUG = 1 << 3 }; static void info(const char *message, ...); @@ -23,6 +24,8 @@ public : static int error(const char *message, ...); + static void debug(const char *message, ...); + private : static void writeln(Type type, const char *fmt, va_list args); diff --git a/source/System/Log.cpp b/source/System/Log.cpp index 257351c..47a5210 100644 --- a/source/System/Log.cpp +++ b/source/System/Log.cpp @@ -35,6 +35,17 @@ int Log::error(const char *message, ...) return 1; } +void Log::debug(const char *message, ...) +{ +#ifdef SPECTRE_DEBUG + va_list vl; + + va_start(vl, message); + writeln(T_DEBUG, message, vl); + va_end(vl); +#endif /* SPECTRE_DEBUG */ +} + void Log::writeln(Type type, const char *message, va_list args) { FILE *fd = stderr; @@ -52,8 +63,12 @@ void Log::writeln(Type type, const char *message, va_list args) case T_CRITICAL: prefix = "CRIT"; break; - default : - case T_ERROR : +#ifdef SPECTRE_DEBUG + case T_DEBUG: + prefix = "DEBUG"; + break; +#endif /* SPECTRE_DEBUG */ + case T_ERROR : default : prefix = "ERROR"; break; }