mirror of
https://github.com/pi-hole/FTL.git
synced 2025-12-20 05:58:25 +00:00
Use get_timestr() instead of ctime_r() to obtain string representation of a timestamp
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
13
gc.c
13
gc.c
@@ -42,13 +42,16 @@ void *GC_thread(void *val)
|
|||||||
mintime -= mintime % 3600;
|
mintime -= mintime % 3600;
|
||||||
mintime += 3600;
|
mintime += 3600;
|
||||||
|
|
||||||
if(config.debug & DEBUG_GC) timer_start(GC_TIMER);
|
if(config.debug & DEBUG_GC)
|
||||||
|
{
|
||||||
int removed = 0;
|
timer_start(GC_TIMER);
|
||||||
char ctimebuffer[32]; // need at least 26 bytes according to ctime_r man page
|
char timestring[84] = "";
|
||||||
if(config.debug & DEBUG_GC) logg("GC starting, mintime: %lu %s", mintime, ctime_r(&mintime, ctimebuffer));
|
get_timestr(timestring, mintime);
|
||||||
|
logg("GC starting, mintime: %s (%lu)", timestring, mintime);
|
||||||
|
}
|
||||||
|
|
||||||
// Process all queries
|
// Process all queries
|
||||||
|
int removed = 0;
|
||||||
for(long int i=0; i < counters->queries; i++)
|
for(long int i=0; i < counters->queries; i++)
|
||||||
{
|
{
|
||||||
queriesData* query = getQuery(i, true);
|
queriesData* query = getQuery(i, true);
|
||||||
|
|||||||
7
log.c
7
log.c
@@ -50,11 +50,10 @@ void open_FTL_log(const bool test)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_timestr(char *timestring)
|
void get_timestr(char *timestring, const time_t timein)
|
||||||
{
|
{
|
||||||
const time_t t = time(NULL);
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
localtime_r(&t, &tm);
|
localtime_r(&timein, &tm);
|
||||||
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
@@ -70,7 +69,7 @@ void __attribute__ ((format (gnu_printf, 1, 2))) logg(const char *format, ...)
|
|||||||
|
|
||||||
pthread_mutex_lock(&lock);
|
pthread_mutex_lock(&lock);
|
||||||
|
|
||||||
get_timestr(timestring);
|
get_timestr(timestring, time(NULL));
|
||||||
|
|
||||||
// Get and log PID of current process to avoid ambiguities when more than one
|
// Get and log PID of current process to avoid ambiguities when more than one
|
||||||
// pihole-FTL instance is logging into the same file
|
// pihole-FTL instance is logging into the same file
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ void logg(const char* format, ...) __attribute__ ((format (gnu_printf, 1, 2)));
|
|||||||
void log_counter_info(void);
|
void log_counter_info(void);
|
||||||
void format_memory_size(char *prefix, unsigned long int bytes, double *formated);
|
void format_memory_size(char *prefix, unsigned long int bytes, double *formated);
|
||||||
void log_FTL_version(bool crashreport);
|
void log_FTL_version(bool crashreport);
|
||||||
|
void get_timestr(char *timestring, const time_t timein);
|
||||||
|
|
||||||
// datastructure.c
|
// datastructure.c
|
||||||
void strtolower(char *str);
|
void strtolower(char *str);
|
||||||
|
|||||||
Reference in New Issue
Block a user