g_error (__VA_ARGS__); \
} } while (0)
-
-#ifdef HOST_WIN32
-# define LOG_LOCALTIME localtime
+#ifndef HOST_WIN32
+# define LOG_TIMESTAMP \
+ do { \
+ time_t t; \
+ struct tm tod; \
+ time(&t); \
+ localtime_r(&t, &tod); \
+ strftime(logTime, sizeof(logTime), "%F %T", &tod); \
+ } while (0)
#else
-# define LOG_LOCALTIME localtime_r
+# define LOG_TIMESTAMP \
+ do { \
+ time_t t; \
+ struct tm *tod; \
+ time(&t); \
+ tod = localtime(&t); \
+ strftime(logTime, sizeof(logTime), "%F %T", tod); \
+ } while (0)
#endif
#define SGEN_LOG(level, format, ...) do { \
if (G_UNLIKELY ((level) <= SGEN_MAX_DEBUG_LEVEL && (level) <= gc_debug_level)) { \
- time_t t; \
- struct tm tod; \
char logTime[80]; \
- time(&t); \
- LOG_LOCALTIME(&t, &tod); \
- strftime(logTime, sizeof(logTime), "%F %T", &tod); \
+ LOG_TIMESTAMP; \
mono_gc_printf (gc_debug_file, "%s " format "\n", logTime, ##__VA_ARGS__); \
} } while (0)
#define SGEN_COND_LOG(level, cond, format, ...) do { \
if (G_UNLIKELY ((level) <= SGEN_MAX_DEBUG_LEVEL && (level) <= gc_debug_level)) { \
if (cond) { \
- time_t t; \
- struct tm tod; \
char logTime[80]; \
- time(&t); \
- LOG_LOCALTIME(&t,&tod); \
- strftime(logTime, sizeof(logTime), "%F %T", &tod); \
+ LOG_TIMESTAMP; \
mono_gc_printf (gc_debug_file, "%s " format "\n", logTime, ##__VA_ARGS__); \
} \
} } while (0)