Skip to content

Commit

Permalink
Added nanosecond parsing option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasengelmann committed Feb 10, 2023
1 parent 41b82bd commit 740f6f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions goaccess.1
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,8 @@ The time taken to serve the request, in microseconds as a decimal number.
The time taken to serve the request, in seconds with milliseconds resolution.
.IP %L
The time taken to serve the request, in milliseconds as a decimal number.
.IP %n
The time taken to serve the request, in nanoseconds.
.IP %^
Ignore this field.
.IP %~
Expand Down
17 changes: 17 additions & 0 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,24 @@ parse_specifier (GLogItem * logitem, char **str, const char *p, const char *end)
contains_usecs (); /* set flag */
free (tkn);
break;
/* time taken to serve the request, in nanoseconds */
case 'n':
/* ignore it if we already have served time */
if (logitem->serve_time)
return 0;
if (!(tkn = parse_string (&(*str), end, 1)))
return spec_err (logitem, SPEC_TOKN_NUL, *p, NULL);

serve_time = strtoull (tkn, &bEnd, 10);
if (tkn == bEnd || *bEnd != '\0' || errno == ERANGE)
serve_time = 0;

/* convert it to microseconds */
logitem->serve_time = (serve_time > 0) ? serve_time / MILS : 0;

contains_usecs (); /* set flag */
free (tkn);
break;
/* UMS: Krypto (TLS) "ECDHE-RSA-AES128-GCM-SHA256" */
case 'k':
/* error to set this twice */
Expand Down

0 comments on commit 740f6f0

Please sign in to comment.