--- previous/src/debug/log.h 2018/04/24 19:32:06 1.1.1.4 +++ previous/src/debug/log.h 2018/04/24 19:33:56 1.1.1.5 @@ -7,6 +7,10 @@ #ifndef HATARI_LOG_H #define HATARI_LOG_H +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #include #include @@ -18,6 +22,7 @@ */ typedef enum { + LOG_NONE, /* invalid LOG level */ /* these present user with a dialog and log the issue */ LOG_FATAL, /* Hatari can't continue unless user resolves issue */ LOG_ERROR, /* something user did directly failed (e.g. save) */ @@ -26,7 +31,6 @@ typedef enum LOG_INFO, /* user action success (e.g. TOS file load) */ LOG_TODO, /* functionality not yet being emulated */ LOG_DEBUG, /* information about internal Hatari working */ - LOG_NONE /* invalid LOG level */ } LOGTYPE; #ifndef __GNUC__ @@ -37,19 +41,28 @@ typedef enum extern int Log_Init(void); extern int Log_SetAlertLevel(int level); extern void Log_UnInit(void); -extern void Log_Printf(LOGTYPE nType, const char *psFormat, ...) +extern void _Log_Printf(LOGTYPE nType, const char *psFormat, ...) __attribute__ ((format (printf, 2, 3))); extern void Log_AlertDlg(LOGTYPE nType, const char *psFormat, ...) __attribute__ ((format (printf, 2, 3))); extern LOGTYPE Log_ParseOptions(const char *OptionStr); extern const char* Log_SetTraceOptions(const char *OptionsStr); extern char *Log_MatchTrace(const char *text, int state); - + #ifndef __GNUC__ #undef __attribute__ #endif - +#define _Log_LOG_FATAL(nType, psFormat, ...) _Log_Printf(nType, psFormat, ## __VA_ARGS__) +#define _Log_LOG_ERROR(nType, psFormat, ...) _Log_Printf(nType, psFormat, ## __VA_ARGS__) +#define _Log_LOG_WARN(nType, psFormat, ...) _Log_Printf(nType, psFormat, ## __VA_ARGS__) +#define _Log_LOG_INFO(nType, psFormat, ...) +#define _Log_LOG_TODO(nType, psFormat, ...) +#define _Log_LOG_DEBUG(nType, psFormat, ...) +#define _Log_LOG_NONE(nType, psFormat, ...) + +#define LOG_LEVEL_COMBINE(prefix, nType, psFormat, ...) prefix ## nType (nType, psFormat, ## __VA_ARGS__) +#define Log_Printf(nType, psFormat, ...) LOG_LEVEL_COMBINE(_Log_,nType, psFormat, ## __VA_ARGS__) /* Tracing * ------- @@ -142,5 +155,8 @@ extern Uint64 LogTraceFlags; #define LOG_TRACE_PRINT(args...) fprintf(TraceFile , args) #endif - +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* HATARI_LOG_H */