summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Cruz <andre@cabine.org>2018-05-17 14:10:35 +0100
committerRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>2018-05-25 21:36:19 +0200
commite145cc3269a55bf998967a8047aa844cbc35c7b0 (patch)
tree7c025667e6ddb1320545bce3d277f14298a27523
parent5b062730175305f57110868183175b25de98a6d6 (diff)
downloaduwsgi-e145cc3269a55bf998967a8047aa844cbc35c7b0.tar.gz
Add "secs" formatting variable
Returns the request time in seconds.
-rw-r--r--core/logging.c6
-rw-r--r--core/utils.c8
-rw-r--r--uwsgi.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/core/logging.c b/core/logging.c
index 10c40c83..1efceeea 100644
--- a/core/logging.c
+++ b/core/logging.c
@@ -1170,6 +1170,11 @@ static ssize_t uwsgi_lf_msecs(struct wsgi_request * wsgi_req, char **buf) {
return strlen(*buf);
}
+static ssize_t uwsgi_lf_secs(struct wsgi_request * wsgi_req, char **buf) {
+ *buf = uwsgi_float2str((wsgi_req->end_of_request - wsgi_req->start_of_request) / 1000000.0);
+ return strlen(*buf);
+}
+
static ssize_t uwsgi_lf_pid(struct wsgi_request * wsgi_req, char **buf) {
*buf = uwsgi_num2str(uwsgi.mypid);
return strlen(*buf);
@@ -1938,6 +1943,7 @@ void uwsgi_register_logchunks() {
r_logchunk(cl);
r_logchunk(micros);
r_logchunk(msecs);
+ r_logchunk(secs);
r_logchunk(tmsecs);
r_logchunk(tmicros);
r_logchunk(time);
diff --git a/core/utils.c b/core/utils.c
index 4da30c44..4edb0fd7 100644
--- a/core/utils.c
+++ b/core/utils.c
@@ -1903,6 +1903,14 @@ char *uwsgi_num2str(int num) {
return str;
}
+char *uwsgi_float2str(float num) {
+
+ char *str = uwsgi_malloc(11);
+
+ snprintf(str, 11, "%f", num);
+ return str;
+}
+
char *uwsgi_64bit2str(int64_t num) {
char *str = uwsgi_malloc(sizeof(MAX64_STR) + 1);
snprintf(str, sizeof(MAX64_STR) + 1, "%lld", (long long) num);
diff --git a/uwsgi.h b/uwsgi.h
index ccdab05e..5c6f581f 100644
--- a/uwsgi.h
+++ b/uwsgi.h
@@ -3372,6 +3372,7 @@ void uwsgi_detach_daemons();
void emperor_loop(void);
char *uwsgi_num2str(int);
+char *uwsgi_float2str(float);
char *uwsgi_64bit2str(int64_t);
char *magic_sub(char *, size_t, size_t *, char *[]);