Skip to content

Commit

Permalink
Get and log PID of current process to avoid ambiguities when more tha…
Browse files Browse the repository at this point in the history
…n one pihole-FTL instance is logging into the same file

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Feb 17, 2019
1 parent 0564727 commit 50ab1dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ void logg(const char *format, ...)

get_timestr(timestring);

// Get and log PID of current process to avoid ambiguities when more than one
// pihole-FTL instance is logging into the same file
long pid = (long)getpid();

// Print to stdout before writing to file
if(!daemonmode)
{
printf("[%s] ", timestring);
printf("[%s %ld] ", timestring, pid);
va_start(args, format);
vprintf(format, args);
va_end(args);
Expand All @@ -86,7 +90,7 @@ void logg(const char *format, ...)
// Write to log file
if(logfile != NULL)
{
fprintf(logfile, "[%s] ", timestring);
fprintf(logfile, "[%s %ld] ", timestring, pid);
va_start(args, format);
vfprintf(logfile, format, args);
va_end(args);
Expand Down

0 comments on commit 50ab1dd

Please sign in to comment.