clogger 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/GIT-VERSION-GEN +1 -1
- data/README +3 -3
- data/ext/clogger_ext/clogger.c +38 -34
- metadata +2 -2
data/GIT-VERSION-GEN
CHANGED
data/README
CHANGED
@@ -24,7 +24,7 @@ is customizable so you can specify exactly which fields to log.
|
|
24
24
|
|
25
25
|
* Pure Ruby version for non-MRI versions of Ruby (or via CLOGGER_PURE=1
|
26
26
|
in the environment). The optional C extension is loaded by default
|
27
|
-
|
27
|
+
under C Ruby and under Rubinius, too.
|
28
28
|
|
29
29
|
== SYNOPSIS
|
30
30
|
|
@@ -131,8 +131,8 @@ on the Rubyforge project page:
|
|
131
131
|
|
132
132
|
* http://rubyforge.org/frs/?group_id=8896
|
133
133
|
|
134
|
-
There is an optional C extension that should be compatible with
|
135
|
-
|
134
|
+
There is an optional C extension that should be compatible with
|
135
|
+
MatzRuby. The extensions should automatically be disabled for users of
|
136
136
|
other Ruby implementations, but be sure to let us know if that's not the
|
137
137
|
case. No pre-built binaries are currently distributed, let us know if
|
138
138
|
you're interested in helping with the release/support effort.
|
data/ext/clogger_ext/clogger.c
CHANGED
@@ -365,12 +365,12 @@ static void append_body_bytes_sent(struct clogger *c)
|
|
365
365
|
rb_str_buf_cat(c->log_buf, buf, nr);
|
366
366
|
}
|
367
367
|
|
368
|
-
static void append_ts(struct clogger *c,
|
368
|
+
static void append_ts(struct clogger *c, VALUE op, struct timespec *ts)
|
369
369
|
{
|
370
370
|
char buf[sizeof(".000000") + ((sizeof(ts->tv_sec) * 8) / 3)];
|
371
371
|
int nr;
|
372
|
-
char *fmt = RSTRING_PTR(op
|
373
|
-
int ndiv = NUM2INT(op
|
372
|
+
char *fmt = RSTRING_PTR(rb_ary_entry(op, 1));
|
373
|
+
int ndiv = NUM2INT(rb_ary_entry(op, 2));
|
374
374
|
int usec = ts->tv_nsec / 1000;
|
375
375
|
|
376
376
|
nr = snprintf(buf, sizeof(buf), fmt,
|
@@ -379,7 +379,7 @@ static void append_ts(struct clogger *c, const VALUE *op, struct timespec *ts)
|
|
379
379
|
rb_str_buf_cat(c->log_buf, buf, nr);
|
380
380
|
}
|
381
381
|
|
382
|
-
static void append_request_time_fmt(struct clogger *c,
|
382
|
+
static void append_request_time_fmt(struct clogger *c, VALUE op)
|
383
383
|
{
|
384
384
|
struct timespec now;
|
385
385
|
|
@@ -388,7 +388,7 @@ static void append_request_time_fmt(struct clogger *c, const VALUE *op)
|
|
388
388
|
append_ts(c, op, &now);
|
389
389
|
}
|
390
390
|
|
391
|
-
static void append_time_fmt(struct clogger *c,
|
391
|
+
static void append_time_fmt(struct clogger *c, VALUE op)
|
392
392
|
{
|
393
393
|
struct timespec now;
|
394
394
|
int r = clock_gettime(CLOCK_REALTIME, &now);
|
@@ -641,35 +641,38 @@ static void special_var(struct clogger *c, enum clogger_special var)
|
|
641
641
|
static VALUE cwrite(struct clogger *c)
|
642
642
|
{
|
643
643
|
const VALUE ops = c->fmt_ops;
|
644
|
-
|
645
|
-
long
|
644
|
+
long i;
|
645
|
+
long len = RARRAY_LEN(ops);
|
646
646
|
VALUE dst = c->log_buf;
|
647
647
|
|
648
648
|
rb_str_set_len(dst, 0);
|
649
649
|
|
650
|
-
for (;
|
651
|
-
|
652
|
-
enum clogger_opcode opcode = FIX2INT(op
|
650
|
+
for (i = 0; i < len; i++) {
|
651
|
+
VALUE op = rb_ary_entry(ops, i);
|
652
|
+
enum clogger_opcode opcode = FIX2INT(rb_ary_entry(op, 0));
|
653
|
+
VALUE op1 = rb_ary_entry(op, 1);
|
653
654
|
|
654
655
|
switch (opcode) {
|
655
656
|
case CL_OP_LITERAL:
|
656
|
-
rb_str_buf_append(dst,
|
657
|
+
rb_str_buf_append(dst, op1);
|
657
658
|
break;
|
658
659
|
case CL_OP_REQUEST:
|
659
|
-
append_request_env(c,
|
660
|
+
append_request_env(c, op1);
|
660
661
|
break;
|
661
662
|
case CL_OP_RESPONSE:
|
662
|
-
append_response(c,
|
663
|
+
append_response(c, op1);
|
663
664
|
break;
|
664
665
|
case CL_OP_SPECIAL:
|
665
|
-
special_var(c, FIX2INT(
|
666
|
+
special_var(c, FIX2INT(op1));
|
666
667
|
break;
|
667
668
|
case CL_OP_EVAL:
|
668
|
-
append_eval(c,
|
669
|
+
append_eval(c, op1);
|
669
670
|
break;
|
670
671
|
case CL_OP_TIME_LOCAL:
|
671
|
-
case CL_OP_TIME_UTC:
|
672
|
-
|
672
|
+
case CL_OP_TIME_UTC: {
|
673
|
+
VALUE arg2 = rb_ary_entry(op, 2);
|
674
|
+
append_time(c, opcode, op1, arg2);
|
675
|
+
}
|
673
676
|
break;
|
674
677
|
case CL_OP_REQUEST_TIME:
|
675
678
|
append_request_time_fmt(c, op);
|
@@ -678,7 +681,7 @@ static VALUE cwrite(struct clogger *c)
|
|
678
681
|
append_time_fmt(c, op);
|
679
682
|
break;
|
680
683
|
case CL_OP_COOKIE:
|
681
|
-
append_cookie(c,
|
684
|
+
append_cookie(c, op1);
|
682
685
|
break;
|
683
686
|
}
|
684
687
|
}
|
@@ -852,16 +855,15 @@ static VALUE ccall(struct clogger *c, VALUE env)
|
|
852
855
|
c->cookies = Qfalse;
|
853
856
|
rv = rb_funcall(c->app, call_id, 1, env);
|
854
857
|
if (TYPE(rv) == T_ARRAY && RARRAY_LEN(rv) == 3) {
|
855
|
-
|
856
|
-
|
857
|
-
c->
|
858
|
-
c->headers = tmp[1];
|
859
|
-
c->body = tmp[2];
|
858
|
+
c->status = rb_ary_entry(rv, 0);
|
859
|
+
c->headers = rb_ary_entry(rv, 1);
|
860
|
+
c->body = rb_ary_entry(rv, 2);
|
860
861
|
|
861
|
-
rv =
|
862
|
+
rv = rb_ary_dup(rv);
|
862
863
|
if (c->need_resp &&
|
863
|
-
! rb_obj_is_kind_of(
|
864
|
-
c->headers = rb_funcall(cHeaderHash, new_id, 1,
|
864
|
+
! rb_obj_is_kind_of(c->headers, cHeaderHash)) {
|
865
|
+
c->headers = rb_funcall(cHeaderHash, new_id, 1,
|
866
|
+
c->headers);
|
865
867
|
rb_ary_store(rv, 1, c->headers);
|
866
868
|
}
|
867
869
|
} else {
|
@@ -919,17 +921,19 @@ static VALUE clogger_call(VALUE self, VALUE env)
|
|
919
921
|
|
920
922
|
static void duplicate_buffers(VALUE ops)
|
921
923
|
{
|
922
|
-
long i
|
923
|
-
|
924
|
+
long i;
|
925
|
+
long len = RARRAY_LEN(ops);
|
924
926
|
|
925
|
-
for ( ;
|
926
|
-
VALUE
|
927
|
-
enum clogger_opcode opcode = FIX2INT(op
|
927
|
+
for (i = 0; i < len; i++) {
|
928
|
+
VALUE op = rb_ary_entry(ops, i);
|
929
|
+
enum clogger_opcode opcode = FIX2INT(rb_ary_entry(op, 0));
|
928
930
|
|
929
931
|
if (opcode == CL_OP_TIME_LOCAL || opcode == CL_OP_TIME_UTC) {
|
930
|
-
|
931
|
-
|
932
|
-
|
932
|
+
VALUE buf = rb_ary_entry(op, 2);
|
933
|
+
Check_Type(buf, T_STRING);
|
934
|
+
buf = rb_str_dup(buf);
|
935
|
+
rb_str_modify(buf); /* trigger copy-on-write */
|
936
|
+
rb_ary_store(op, 2, buf);
|
933
937
|
}
|
934
938
|
}
|
935
939
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|