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)
mono_log_write_logfile(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *format, va_list args)
{
time_t t;
- struct tm tod;
char logTime[80],
logMessage[512];
pid_t pid;
logFile = stdout;
if (hdr) {
- time(&t);
#ifndef HOST_WIN32
+ struct tm tod;
+ time(&t);
localtime_r(&t, &tod);
pid = getpid();
+ strftime(logTime, sizeof(logTime), "%F %T", &tod);
#else
- localtime(&t, &tod);
+ struct tm *tod;
+ time(&t);
+ tod = localtime(&t);
pid = _getpid();
+ strftime(logTime, sizeof(logTime), "%F %T", tod);
#endif
- strftime(logTime, sizeof(logTime), "%F %T", &tod);
iLog = snprintf(logMessage, sizeof(logMessage), "%s level[%c] mono[%d]: ",
logTime,mapLogFileLevel(level),pid);
}
mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *format, va_list args)
{
time_t t;
- struct tm tod;
+ struct tm *tod;
char logTime[80],
logMessage[512];
pid_t pid;
mono_log_open_logfile(NULL, NULL);
time(&t);
- localtime(&t, &tod);
+ tod = localtime(&t);
pid = _getpid();
- strftime(logTime, sizeof(logTime), "%F %T", &tod);
+ strftime(logTime, sizeof(logTime), "%F %T", tod);
iLog = snprintf(logMessage, sizeof(logMessage), "%s level[%c] mono[%d]: ",
logTime,mapLogFileLevel(level),pid);
nLog = sizeof(logMessage) - iLog - 2;