Skip to content

Commit

Permalink
Merge pull request #229 from flaviojs/change-timestamp-iso8601-m_flog
Browse files Browse the repository at this point in the history
Change the timestamp to ISO8601 in m_flog.
  • Loading branch information
grossmj authored Apr 5, 2024
2 parents 38de9d8 + e5d21ec commit 65552d3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,13 @@ void m_flog(FILE *fd,char *module,char *fmt,va_list ap)
{
struct timespec spec;
struct tm tmn;
char buf[256];

if (fd != NULL) {
clock_gettime(CLOCK_REALTIME, &spec);
gmtime_r(&spec.tv_sec, &tmn);

strftime(buf,sizeof(buf),"%b %d %H:%M:%S",&tmn);

fprintf(fd,"%s.%03ld %s: ",buf,(long)spec.tv_nsec/1000000,module);
// NOTE never use strftime for timestamps, it is crashy
fprintf(fd,"%d-%02d-%02dT%02d:%02d:%02d.%03dZ %s: ",tmn.tm_year+1900,tmn.tm_mon+1,tmn.tm_mday,tmn.tm_hour,tmn.tm_min,tmn.tm_sec,(int)(spec.tv_nsec/1000000),module);
vfprintf(fd,fmt,ap);
fflush(fd);
}
Expand Down

0 comments on commit 65552d3

Please sign in to comment.