Skip to content

Commit

Permalink
fix #73: When running in foreground Error logs do not have time stamps
Browse files Browse the repository at this point in the history
  • Loading branch information
ballle98 committed May 20, 2024
1 parent c12e0cf commit b71a13d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,14 @@ void _LOG(int16_t from, int msg_level, char *message)
#endif //AQ_MANAGER

if (_daemonise == FALSE) {
struct timespec tspec;
struct tm localtm;
clock_gettime(CLOCK_REALTIME, &tspec);
char timeStr[TIMESTAMP_LENGTH];
strftime(timeStr, sizeof(timeStr), "%H:%M:%S", localtime_r(&tspec.tv_sec, &localtm));
if (msg_level == LOG_ERR) {
fprintf(stderr, "%s", message);
fprintf(stderr, "%s.%03ld %s", timeStr, tspec.tv_nsec / 1000000L, message);
} else {
struct timespec tspec;
struct tm localtm;
clock_gettime(CLOCK_REALTIME, &tspec);
char timeStr[TIMESTAMP_LENGTH];
strftime(timeStr, sizeof(timeStr), "%H:%M:%S", localtime_r(&tspec.tv_sec, &localtm));
printf("%s.%03ld %s", timeStr, tspec.tv_nsec / 1000000L, message);
}
}
Expand Down

0 comments on commit b71a13d

Please sign in to comment.