From 6fc62f8c93bd81f6207fcbdfe332b4e56c2aa2be Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 29 May 2014 23:03:03 -0400 Subject: log: fixed to not print twice, enabled coloring, added OS print logging as its own type --- src/common/log.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/common/log.h') diff --git a/src/common/log.h b/src/common/log.h index 8b39b03a1..2543b51a8 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -7,11 +7,14 @@ #define LOGGING -#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports. -#define ERROR_LEVEL 2 // Critical errors -#define WARNING_LEVEL 3 // Something is suspicious. -#define INFO_LEVEL 4 // General information. -#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. +enum { + OS_LEVEL, // Printed by the emulated operating system + NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports. + ERROR_LEVEL, // Critical errors + WARNING_LEVEL, // Something is suspicious. + INFO_LEVEL, // General information. + DEBUG_LEVEL, // Detailed debugging - might make things slow. +}; namespace LogTypes { @@ -70,6 +73,7 @@ enum LOG_TYPE { // FIXME: should this be removed? enum LOG_LEVELS { + LOS = OS_LEVEL, LNOTICE = NOTICE_LEVEL, LERROR = ERROR_LEVEL, LWARNING = WARNING_LEVEL, @@ -82,8 +86,8 @@ enum LOG_LEVELS { } // namespace -void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, - const char *file, int line, const char *fmt, ...) +void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line, + const char* function, const char* fmt, ...) #ifdef __GNUC__ __attribute__((format(printf, 5, 6))) #endif @@ -97,16 +101,19 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, #endif // loglevel #endif // logging -#ifdef GEKKO -#define GENERIC_LOG(t, v, ...) -#else +#ifdef _WIN32 +#ifndef __func__ +#define __func__ __FUNCTION__ +#endif +#endif + // Let the compiler optimize this out #define GENERIC_LOG(t, v, ...) { \ if (v <= MAX_LOGLEVEL) \ - GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ + GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \ } -#endif +#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __VA_ARGS__) } while (0) #define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (0) #define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (0) #define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0) -- cgit v1.2.3 From 5cd922d1514e629f1aa0d7083272e51decb61175 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 10:57:45 -0400 Subject: log: updated GenericLog __attribute__ for newly added parameter --- src/common/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/log.h') diff --git a/src/common/log.h b/src/common/log.h index 2543b51a8..3518d4e1d 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -89,7 +89,7 @@ enum LOG_LEVELS { void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line, const char* function, const char* fmt, ...) #ifdef __GNUC__ - __attribute__((format(printf, 5, 6))) + __attribute__((format(printf, 6, 7))) #endif ; -- cgit v1.2.3 From 00adbc7817194183dbea95ddfdb8678a5571c799 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 1 Jun 2014 11:49:58 -0400 Subject: log: updated MAX_LOGLEVEL to use correct log level enum type --- src/common/log.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common/log.h') diff --git a/src/common/log.h b/src/common/log.h index 3518d4e1d..a3c8bdde6 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -94,10 +94,10 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int ; #if defined LOGGING || defined _DEBUG || defined DEBUGFAST -#define MAX_LOGLEVEL DEBUG_LEVEL +#define MAX_LOGLEVEL LDEBUG #else #ifndef MAX_LOGLEVEL -#define MAX_LOGLEVEL WARNING_LEVEL +#define MAX_LOGLEVEL LWARNING #endif // loglevel #endif // logging @@ -109,7 +109,7 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int // Let the compiler optimize this out #define GENERIC_LOG(t, v, ...) { \ - if (v <= MAX_LOGLEVEL) \ + if (v <= LogTypes::MAX_LOGLEVEL) \ GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \ } -- cgit v1.2.3