Mercurial > hg > nginx
diff src/core/ngx_times.c @ 3873:eae4a59ae59a
$time_iso8601 log variable
patch by Michael Lustfield
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 16 Mar 2011 15:46:57 +0000 |
parents | 72c3edbd4dc8 |
children | d620f497c50f |
line wrap: on
line diff
--- a/src/core/ngx_times.c Wed Mar 16 15:32:31 2011 +0000 +++ b/src/core/ngx_times.c Wed Mar 16 15:46:57 2011 +0000 @@ -27,6 +27,7 @@ volatile ngx_str_t ngx_cached_err_log_time; volatile ngx_str_t ngx_cached_http_time; volatile ngx_str_t ngx_cached_http_log_time; +volatile ngx_str_t ngx_cached_http_log_iso8601; #if !(NGX_WIN32) @@ -46,6 +47,8 @@ [sizeof("Mon, 28 Sep 1970 06:00:00 GMT")]; static u_char cached_http_log_time[NGX_TIME_SLOTS] [sizeof("28/Sep/1970:12:00:00 +0600")]; +static u_char cached_http_log_iso8601[NGX_TIME_SLOTS] + [sizeof("1970-09-28T12:00:00+06:00")]; static char *week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; @@ -58,6 +61,7 @@ ngx_cached_err_log_time.len = sizeof("1970/09/28 12:00:00") - 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; ngx_cached_time = &cached_time[0]; @@ -68,7 +72,7 @@ void ngx_time_update(void) { - u_char *p0, *p1, *p2; + u_char *p0, *p1, *p2, *p3; ngx_tm_t tm, gmt; time_t sec; ngx_uint_t msec; @@ -152,6 +156,15 @@ tp->gmtoff < 0 ? '-' : '+', ngx_abs(tp->gmtoff / 60), ngx_abs(tp->gmtoff % 60)); + p3 = &cached_http_log_iso8601[slot][0]; + + (void) ngx_sprintf(p3, "%4d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", + tm.ngx_tm_year, tm.ngx_tm_mon, + tm.ngx_tm_mday, tm.ngx_tm_hour, + tm.ngx_tm_min, tm.ngx_tm_sec, + tp->gmtoff < 0 ? '-' : '+', + ngx_abs(tp->gmtoff / 60), ngx_abs(tp->gmtoff % 60)); + ngx_memory_barrier(); @@ -159,6 +172,7 @@ ngx_cached_http_time.data = p0; ngx_cached_err_log_time.data = p1; ngx_cached_http_log_time.data = p2; + ngx_cached_http_log_iso8601.data = p3; ngx_unlock(&ngx_time_lock); }