Project

General

Profile

Optimization #1718 ยป iso-time-format.patch

patch for ISO format time stamps in log files - Joachim Schwender, 02/22/2016 02:42 AM

View differences:

src-new/detect-engine-analyzer.c 2016-02-22 09:05:51.000000000 +0100
struct tm local_tm;
tms = SCLocalTime(tval.tv_sec, &local_tm);
fprintf(fp_engine_analysis_FD, "----------------------------------------------"
"---------------------\n");
fprintf(fp_engine_analysis_FD, "Date: %" PRId32 "/%" PRId32 "/%04d -- "
fprintf(fp_engine_analysis_FD, "Date: %04d-%02d-%02d -- " // ISO format time stamp
"%02d:%02d:%02d\n",
tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour,
tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday, tms->tm_hour, // ISO format time stamp
tms->tm_min, tms->tm_sec);
fprintf(fp_engine_analysis_FD, "----------------------------------------------"
"---------------------\n");
......
struct tm local_tm;
tms = SCLocalTime(tval.tv_sec, &local_tm);
fprintf(rule_engine_analysis_FD, "----------------------------------------------"
"---------------------\n");
fprintf(rule_engine_analysis_FD, "Date: %" PRId32 "/%" PRId32 "/%04d -- "
fprintf(rule_engine_analysis_FD, "Date: %04d-%02d-%02d -- " // ISO format time stamp
"%02d:%02d:%02d\n",
tms->tm_mday, tms->tm_mon + 1, tms->tm_year + 1900, tms->tm_hour,
tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday, tms->tm_hour, // ISO format time stamp
tms->tm_min, tms->tm_sec);
fprintf(rule_engine_analysis_FD, "----------------------------------------------"
"---------------------\n");
src-new/log-stats.c 2016-02-22 09:06:54.000000000 +0100
int days = in_hours / 24;
MemBufferWriteString(aft->buffer, "----------------------------------------------"
"---------------------\n");
MemBufferWriteString(aft->buffer, "Date: %" PRId32 "/%" PRId32 "/%04d -- "
MemBufferWriteString(aft->buffer, "Date: %04d-%02d-%02d -- " // ISO format time stamp
"%02d:%02d:%02d (uptime: %"PRId32"d, %02dh %02dm %02ds)\n",
tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900, tms->tm_hour,
tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday, tms->tm_hour, // ISO format time stamp
tms->tm_min, tms->tm_sec, days, hours, min, sec);
MemBufferWriteString(aft->buffer, "----------------------------------------------"
"---------------------\n");
MemBufferWriteString(aft->buffer, "%-25s | %-25s | %-s\n", "Counter", "TM Name",
src-new/util-debug.c 2016-02-22 09:18:18.000000000 +0100
struct tm local_tm;
tms = SCLocalTime(tval->tv_sec, &local_tm);
cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - buffer),
"%s%s%d/%d/%04d -- %02d:%02d:%02d%s",
substr, green, tms->tm_mday, tms->tm_mon + 1,
tms->tm_year + 1900, tms->tm_hour, tms->tm_min,
"%s%s%04d-%02d-%02d -- %02d:%02d:%02d%s", // ISO format time stamp
substr, green, tms->tm_year + 1900, tms->tm_mon + 1, // ISO format time stamp
tms->tm_mday, tms->tm_hour, tms->tm_min, // ISO format time stamp
tms->tm_sec, reset);
if (cw < 0)
goto error;
temp += cw;
src-new/util-profiling-keywords.c 2016-02-22 09:07:52.000000000 +0100
fprintf(fp, " ----------------------------------------------"
"------------------------------------------------------"
"----------------------------\n");
fprintf(fp, " Date: %" PRId32 "/%" PRId32 "/%04d -- "
"%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
fprintf(fp, " Date: %04d-%02d-%02d -- " // ISO format time stamp
"%02d:%02d:%02d\n", tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday, // ISO format time stamp
tms->tm_hour,tms->tm_min, tms->tm_sec);
/* global stats first */
DoDump(de_ctx->profile_keyword_ctx, fp, "total");
src-new/util-profiling-rules.c 2016-02-22 09:07:26.000000000 +0100
tms = SCLocalTime(tval.tv_sec, &local_tm);
fprintf(fp, " ----------------------------------------------"
"----------------------------\n");
fprintf(fp, " Date: %" PRId32 "/%" PRId32 "/%04d -- "
"%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
fprintf(fp, " Date: %04d-%02d-%02d -- " // ISO format time stamp
"%02d:%02d:%02d\n", tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday, // ISO format time stamp
tms->tm_hour,tms->tm_min, tms->tm_sec);
fprintf(fp, " ----------------------------------------------"
"----------------------------\n");
fprintf(fp, " %-8s %-12s %-8s %-8s %-12s %-6s %-8s %-8s %-11s %-11s %-11s %-11s\n", "Num", "Rule", "Gid", "Rev", "Ticks", "%", "Checks", "Matches", "Max Ticks", "Avg Ticks", "Avg Match", "Avg No Match");
src-new/util-time.c 2016-02-22 09:21:53.000000000 +0100
struct tm local_tm;
struct tm *t = (struct tm*)SCLocalTime(time, &local_tm);
if (likely(t != NULL)) {
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
snprintf(str, size, "%04d-%02d-%02dT%02d:%02d:%02d.%06u", // ISO format time stamp
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, // ISO format time stamp
t->tm_min, t->tm_sec, (uint32_t) ts->tv_usec);
} else {
snprintf(str, size, "ts-error");
}
......
{
struct tm local_tm;
struct tm *t = (struct tm *)SCLocalTime(time, &local_tm);
int cached_len = snprintf(cached_local_time[n], MAX_LOCAL_TIME_STRING,
"%02d/%02d/%02d-%02d:%02d:",
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900,
"%04d-%02d-%02dT%02d:%02d:", // ISO format time stamp
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, // ISO format time stamp
t->tm_hour, t->tm_min);
cached_local_time_len[n] = cached_len;
/* Store the time of the beginning of the minute. */
last_local_time[n] = time - t->tm_sec;
    (1-1/1)