Update log time on every entry #1443

This commit is contained in:
Ian Craggs 2024-12-20 19:12:09 +00:00
parent c854d7a4cd
commit b92e506ebc
1 changed files with 5 additions and 23 deletions

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2023 IBM Corp.
* Copyright (c) 2009, 2024 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -84,7 +84,6 @@ typedef struct
#else
struct timeb ts;
#endif
int sametime_count;
int number;
thread_id_type thread_id;
int depth;
@ -117,11 +116,10 @@ static FILE* Log_destToFile(const char *dest);
static int Log_compareEntries(const char *entry1, const char *entry2);
#endif
static int sametime_count = 0;
#if defined(GETTIMEOFDAY)
struct timeval now_ts, last_ts;
struct timeval now_ts;
#else
struct timeb now_ts, last_ts;
struct timeb now_ts;
#endif
static char msg_buf[512];
@ -259,7 +257,6 @@ void Log_terminate(void)
start_index = -1;
next_index = 0;
trace_output_level = INVALID_LEVEL;
sametime_count = 0;
}
@ -267,21 +264,11 @@ static traceEntry* Log_pretrace(void)
{
traceEntry *cur_entry = NULL;
/* calling ftime/gettimeofday seems to be comparatively expensive, so we need to limit its use */
if (++sametime_count % 20 == 0)
{
#if defined(GETTIMEOFDAY)
gettimeofday(&now_ts, NULL);
if (now_ts.tv_sec != last_ts.tv_sec || now_ts.tv_usec != last_ts.tv_usec)
gettimeofday(&now_ts, NULL);
#else
ftime(&now_ts);
if (now_ts.time != last_ts.time || now_ts.millitm != last_ts.millitm)
ftime(&now_ts);
#endif
{
sametime_count = 0;
last_ts = now_ts;
}
}
if (trace_queue_size != trace_settings.max_trace_entries)
{
@ -333,8 +320,6 @@ static char* Log_formatTraceEntry(traceEntry* cur_entry)
snprintf(&msg_buf[22], sizeof(msg_buf)-22, ".%.3hu ", cur_entry->ts.millitm);
#endif
buf_pos = 27;
snprintf(msg_buf, sizeof(msg_buf), "(%.4d)", cur_entry->sametime_count);
msg_buf[6] = ' ';
if (cur_entry->has_rc == 2)
@ -403,8 +388,6 @@ static void Log_trace(enum LOG_LEVELS log_level, const char *buf)
cur_entry = Log_pretrace();
memcpy(&(cur_entry->ts), &now_ts, sizeof(now_ts));
cur_entry->sametime_count = sametime_count;
cur_entry->has_rc = 2;
strncpy(cur_entry->name, buf, sizeof(cur_entry->name));
cur_entry->name[MAX_FUNCTION_NAME_LENGTH] = '\0';
@ -467,7 +450,6 @@ void Log_stackTrace(enum LOG_LEVELS log_level, int msgno, thread_id_type thread_
cur_entry = Log_pretrace();
memcpy(&(cur_entry->ts), &now_ts, sizeof(now_ts));
cur_entry->sametime_count = sametime_count;
cur_entry->number = msgno;
cur_entry->thread_id = thread_id;
cur_entry->depth = current_depth;