Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created February 5, 2019 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyaevseev/ca636314e1ba2a7889c7efca5d85f594 to your computer and use it in GitHub Desktop.
Save ilyaevseev/ca636314e1ba2a7889c7efca5d85f594 to your computer and use it in GitHub Desktop.
Try to put Nginx error_log records with millisecond measurement (NOT TESTED!!)
hg diff -p
diff -r e72c8a8a8b10 src/core/ngx_times.c
--- a/src/core/ngx_times.c Thu Jan 31 19:36:51 2019 +0300
+++ b/src/core/ngx_times.c Tue Feb 05 10:12:03 2019 +0300
@@ -47,7 +47,7 @@ static ngx_int_t cached_gmtoff;
static ngx_time_t cached_time[NGX_TIME_SLOTS];
static u_char cached_err_log_time[NGX_TIME_SLOTS]
- [sizeof("1970/09/28 12:00:00")];
+ [sizeof("1970/09/28 12:00:00.000")];
static u_char cached_http_time[NGX_TIME_SLOTS]
[sizeof("Mon, 28 Sep 1970 06:00:00 GMT")];
static u_char cached_http_log_time[NGX_TIME_SLOTS]
@@ -65,7 +65,7 @@ static char *months[] = { "Jan", "Feb",
void
ngx_time_init(void)
{
- ngx_cached_err_log_time.len = sizeof("1970/09/28 12:00:00") - 1;
+ ngx_cached_err_log_time.len = sizeof("1970/09/28 12:00:00.000") - 1;
ngx_cached_http_time.len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1;
ngx_cached_http_log_time.len = sizeof("28/Sep/1970:12:00:00 +0600") - 1;
ngx_cached_http_log_iso8601.len = sizeof("1970-09-28T12:00:00+06:00") - 1;
@@ -149,10 +149,10 @@ ngx_time_update(void)
p1 = &cached_err_log_time[slot][0];
- (void) ngx_sprintf(p1, "%4d/%02d/%02d %02d:%02d:%02d",
+ (void) ngx_sprintf(p1, "%4d/%02d/%02d %02d:%02d:%02d.%03d",
tm.ngx_tm_year, tm.ngx_tm_mon,
tm.ngx_tm_mday, tm.ngx_tm_hour,
- tm.ngx_tm_min, tm.ngx_tm_sec);
+ tm.ngx_tm_min, tm.ngx_tm_sec, msec);
p2 = &cached_http_log_time[slot][0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment