Welcome! Log In Create A New Profile

Advanced

[PATCH] Variable $time_short.

Gena Makhomed
May 26, 2021 04:44PM
# HG changeset patch
# User Gena Makhomed <gmm@csdoc.com>
# Date 1622061379 -10800
# Wed May 26 23:36:19 2021 +0300
# Node ID b3c942ec8a13bc8f6cd4b3e2385acb8c14502c0d
# Parent f5de03f308a6d7864b7d5108a968db56585b9a9b
Variable $time_short.

Variable $time_short in form "1970/09/28 12:00:00".
Added to ngx_http_core_module, ngx_http_log_module,
and ngx_stream_core_module.

diff -r f5de03f308a6 -r b3c942ec8a13 src/http/modules/ngx_http_log_module.c
--- a/src/http/modules/ngx_http_log_module.c Tue May 25 15:28:56 2021 +0300
+++ b/src/http/modules/ngx_http_log_module.c Wed May 26 23:36:19 2021 +0300
@@ -115,6 +115,8 @@
ngx_http_log_op_t *op);
static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op);
+static u_char *ngx_http_log_time_short(ngx_http_request_t *r, u_char *buf,
+ ngx_http_log_op_t *op);
static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op);
static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf,
@@ -234,6 +236,8 @@
{ ngx_string("pipe"), 1, ngx_http_log_pipe },
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
ngx_http_log_time },
+ { ngx_string("time_short"), sizeof("1970/09/28 12:00:00") - 1,
+ ngx_http_log_time_short },
{ ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1,
ngx_http_log_iso8601 },
{ ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
@@ -817,6 +821,13 @@
}

static u_char *
+ngx_http_log_time_short(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op)
+{
+ return ngx_cpymem(buf, ngx_cached_err_log_time.data,
+ ngx_cached_err_log_time.len);
+}
+
+static u_char *
ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op)
{
return ngx_cpymem(buf, ngx_cached_http_log_iso8601.data,
diff -r f5de03f308a6 -r b3c942ec8a13 src/http/ngx_http_variables.c
--- a/src/http/ngx_http_variables.c Tue May 25 15:28:56 2021 +0300
+++ b/src/http/ngx_http_variables.c Wed May 26 23:36:19 2021 +0300
@@ -142,6 +142,8 @@
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_time_iso8601(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_time_short(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_time_local(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);

@@ -362,6 +364,9 @@
{ ngx_string("time_iso8601"), NULL, ngx_http_variable_time_iso8601,
0, NGX_HTTP_VAR_NOCACHEABLE, 0 },

+ { ngx_string("time_short"), NULL, ngx_http_variable_time_short,
+ 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
{ ngx_string("time_local"), NULL, ngx_http_variable_time_local,
0, NGX_HTTP_VAR_NOCACHEABLE, 0 },

@@ -2380,6 +2385,29 @@


static ngx_int_t
+ngx_http_variable_time_short(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+
+ p = ngx_pnalloc(r->pool, ngx_cached_err_log_time.len);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_memcpy(p, ngx_cached_err_log_time.data,
ngx_cached_err_log_time.len);
+
+ v->len = ngx_cached_err_log_time.len;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_variable_time_local(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
diff -r f5de03f308a6 -r b3c942ec8a13 src/stream/ngx_stream_variables.c
--- a/src/stream/ngx_stream_variables.c Tue May 25 15:28:56 2021 +0300
+++ b/src/stream/ngx_stream_variables.c Wed May 26 23:36:19 2021 +0300
@@ -46,6 +46,8 @@
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_time_iso8601(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_time_short(ngx_stream_session_t *s,
+ ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_time_local(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_protocol(ngx_stream_session_t *s,
@@ -115,6 +117,9 @@
{ ngx_string("time_iso8601"), NULL, ngx_stream_variable_time_iso8601,
0, NGX_STREAM_VAR_NOCACHEABLE, 0 },

+ { ngx_string("time_short"), NULL, ngx_stream_variable_time_short,
+ 0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
+
{ ngx_string("time_local"), NULL, ngx_stream_variable_time_local,
0, NGX_STREAM_VAR_NOCACHEABLE, 0 },

@@ -875,6 +880,29 @@


static ngx_int_t
+ngx_stream_variable_time_short(ngx_stream_session_t *s,
+ ngx_stream_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+
+ p = ngx_pnalloc(s->connection->pool, ngx_cached_err_log_time.len);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_memcpy(p, ngx_cached_err_log_time.data,
ngx_cached_err_log_time.len);
+
+ v->len = ngx_cached_err_log_time.len;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_stream_variable_time_local(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data)
{

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Variable $time_short.

Gena Makhomed 379 May 26, 2021 04:44PM

Re: [PATCH] Variable $time_short.

Maxim Dounin 108 May 27, 2021 01:26PM

Re: [PATCH] Variable $time_short.

Gena Makhomed 83 May 27, 2021 02:50PM

Re: [PATCH] Variable $time_short.

Maxim Dounin 96 May 28, 2021 05:56PM

Re: [PATCH] Variable $time_short.

Gena Makhomed 91 May 30, 2021 06:04AM

Re: [PATCH] Variable $time_short.

Maxim Dounin 136 May 31, 2021 12:08PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 287
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready