Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ void initConfig(struct config *conf)
conf->debug.webserver.c = validate_stub; // Only type-based checking

conf->debug.extra.k = "debug.extra";
conf->debug.extra.h = "Temporary flag that may print additional information. This debug flag is meant to be used whenever needed for temporary investigations. The logged content may change without further notice at any time.";
conf->debug.extra.h = "Temporary flag that may print additional information. This debug flag is meant to be used whenever needed for temporary investigations. The logged content may change without further notice at any time. Enabling this flag also raises the resolution of all log timestamps from milliseconds to microseconds.";
conf->debug.extra.t = CONF_BOOL;
conf->debug.extra.d.b = false;
conf->debug.extra.c = validate_stub; // Only type-based checking
Expand Down
11 changes: 8 additions & 3 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ void get_timestr(char timestring[TIMESTR_SIZE], const time_t timein, const bool
{
struct timeval tv;
gettimeofday(&tv, NULL);
const int millisec = tv.tv_usec/1000;

snprintf(timestring, TIMESTR_SIZE, "%d-%02d-%02d%c%02d%c%02d%c%02d.%03i%c%s",
// debug.extra bumps the resolution to microseconds so events
// happening within the same millisecond can still be ordered
const bool micros = config.debug.extra.v.b;
const int subsec = micros ? (int)tv.tv_usec : (int)(tv.tv_usec/1000);
Comment on lines +110 to +113

snprintf(timestring, TIMESTR_SIZE, "%d-%02d-%02d%c%02d%c%02d%c%02d.%0*i%c%s",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, space,
tm.tm_hour, colon, tm.tm_min, colon, tm.tm_sec, millisec, space, tm.tm_zone);
tm.tm_hour, colon, tm.tm_min, colon, tm.tm_sec, micros ? 6 : 3, subsec,
space, tm.tm_zone);
}
else
{
Expand Down
Loading