strlcat(local_format, "%M", sizeof(local_format));
char *temp_fmt = local_format;
char *substr = temp_fmt;
+ struct tm local_tm;
- while ( (temp_fmt = strchr(temp_fmt, SC_LOG_FMT_PREFIX)) ) {
+ while ((temp_fmt = strchr(temp_fmt, SC_LOG_FMT_PREFIX))) {
if ((temp - buffer) > SC_LOG_MAX_LOG_MSG_LEN) {
return 0;
}
case SC_LOG_FMT_TIME:
temp_fmt[0] = '\0';
- struct tm local_tm;
+ tms = SCLocalTime(tval->tv_sec, &local_tm);
+
+ cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - buffer),
+ "%s%s%04d-%02d-%02d %02d:%02d:%02d%s", substr, green, tms->tm_year + 1900,
+ tms->tm_mon + 1, tms->tm_mday, tms->tm_hour, tms->tm_min, tms->tm_sec,
+ reset);
+ if (cw < 0)
+ return -1;
+ temp += cw;
+ temp_fmt++;
+ substr = temp_fmt;
+ substr++;
+ break;
+
+ case SC_LOG_FMT_TIME_LEGACY:
+ temp_fmt[0] = '\0';
+
tms = SCLocalTime(tval->tv_sec, &local_tm);
cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - buffer),
}
}
temp_fmt++;
- }
+ }
if ((temp - buffer) > SC_LOG_MAX_LOG_MSG_LEN) {
return 0;
}
} SCLogConfig;
/* The different log format specifiers supported by the API */
-#define SC_LOG_FMT_TIME 't' /* Timestamp in standard format */
+#define SC_LOG_FMT_TIME 'z' /* Timestamp in RFC3339 like format */
+#define SC_LOG_FMT_TIME_LEGACY 't' /* Timestamp in legacy format */
#define SC_LOG_FMT_PID 'p' /* PID */
#define SC_LOG_FMT_TID 'i' /* Thread ID */
#define SC_LOG_FMT_TM 'm' /* Thread module name */