Adding patch to prefix timestamp to stdout/stderr if LogTime is enabled. Patch courtesy of Andreas Schulze.

pull/75/merge
Micah Snyder 7 years ago
parent a8c02b5ea3
commit a780b81031
  1. 24
      shared/output.c

@ -391,12 +391,13 @@ int logg(const char *str, ...)
/* Need to avoid logging time for verbose messages when logverbose
is not set or we get a bunch of timestamps in the log without
newlines... */
if(logg_time && ((*buff != '*') || logg_verbose)) {
if (logg_time && ((*buff != '*') || logg_verbose))
{
char timestr[32];
time(&currtime);
cli_ctime(&currtime, timestr, sizeof(timestr));
/* cut trailing \n */
timestr[strlen(timestr)-1] = '\0';
timestr[strlen(timestr) - 1] = '\0';
fprintf(logg_fp, "%s -> ", timestr);
}
@ -418,10 +419,25 @@ int logg(const char *str, ...)
fflush(logg_fp);
}
if(logg_foreground) {
if(buff[0] != '#')
if (logg_foreground)
{
if (buff[0] != '#')
{
if (logg_time)
{
char timestr[32];
time(&currtime);
cli_ctime(&currtime, timestr, sizeof(timestr));
/* cut trailing \n */
timestr[strlen(timestr) - 1] = '\0';
mprintf("%s -> %s", timestr, buff);
}
else
{
mprintf("%s", buff);
}
}
}
#if defined(USE_SYSLOG) && !defined(C_AIX)
if(logg_syslog) {

Loading…
Cancel
Save