clogger 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.wrongdoc.yml +2 -2
- data/GIT-VERSION-GEN +1 -1
- data/README +2 -2
- data/Rakefile +2 -2
- data/ext/clogger_ext/blocking_helpers.h +58 -0
- data/ext/clogger_ext/clogger.c +28 -19
- data/ext/clogger_ext/extconf.rb +2 -0
- data/lib/clogger.rb +0 -3
- data/pkg.mk +15 -10
- metadata +8 -7
data/.wrongdoc.yml
CHANGED
data/GIT-VERSION-GEN
CHANGED
data/README
CHANGED
@@ -96,12 +96,12 @@ that receives a "<<" method:
|
|
96
96
|
|
97
97
|
The latest development happens in git and is published to the following:
|
98
98
|
|
99
|
-
git://
|
99
|
+
git://bogomips.org/clogger.git
|
100
100
|
git://repo.or.cz/clogger.git
|
101
101
|
|
102
102
|
You may also browse and download snapshot tarballs:
|
103
103
|
|
104
|
-
* http://
|
104
|
+
* http://bogomips.org/clogger.git (cgit)
|
105
105
|
* http://repo.or.cz/w/clogger.git (gitweb)
|
106
106
|
|
107
107
|
The mailing list (see below) is central for coordination and
|
data/Rakefile
CHANGED
@@ -5,8 +5,8 @@ rescue LoadError
|
|
5
5
|
warn "rake-compiler not available, cross compiling disabled"
|
6
6
|
end
|
7
7
|
|
8
|
-
cgit_url = "http://
|
9
|
-
git_url = 'git://
|
8
|
+
cgit_url = "http://bogomips.org/clogger.git"
|
9
|
+
git_url = 'git://bogomips.org/clogger.git'
|
10
10
|
|
11
11
|
desc "post news article to rubyforge"
|
12
12
|
task :publish_news do
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
2
|
+
struct stat_args { const char *path; struct stat *buf; };
|
3
|
+
static VALUE ng_stat(void *ptr)
|
4
|
+
{
|
5
|
+
struct stat_args *a = ptr;
|
6
|
+
return (VALUE)stat(a->path, a->buf);
|
7
|
+
}
|
8
|
+
static int my_stat(const char *path, struct stat *buf)
|
9
|
+
{
|
10
|
+
struct stat_args a;
|
11
|
+
|
12
|
+
a.path = path;
|
13
|
+
a.buf = buf;
|
14
|
+
return (int)rb_thread_blocking_region(ng_stat, &a, RUBY_UBF_IO, 0);
|
15
|
+
}
|
16
|
+
#ifndef HAVE_RB_THREAD_IO_BLOCKING_REGION
|
17
|
+
# define rb_thread_io_blocking_region(fn,data,fd) \
|
18
|
+
rb_thread_blocking_region((fn),(data), RUBY_UBF_IO, 0)
|
19
|
+
#endif
|
20
|
+
|
21
|
+
struct fstat_args { int fd; struct stat *buf; };
|
22
|
+
static VALUE ng_fstat(void *ptr)
|
23
|
+
{
|
24
|
+
struct fstat_args *a = ptr;
|
25
|
+
return (VALUE)fstat(a->fd, a->buf);
|
26
|
+
}
|
27
|
+
|
28
|
+
static int my_fstat(int fd, struct stat *buf)
|
29
|
+
{
|
30
|
+
struct fstat_args a;
|
31
|
+
|
32
|
+
a.fd = fd;
|
33
|
+
a.buf = buf;
|
34
|
+
return (int)rb_thread_io_blocking_region(ng_fstat, &a, fd);
|
35
|
+
}
|
36
|
+
|
37
|
+
struct write_args { int fd; const void *buf; size_t count; };
|
38
|
+
static VALUE ng_write(void *ptr)
|
39
|
+
{
|
40
|
+
struct write_args *a = ptr;
|
41
|
+
return (VALUE)write(a->fd, a->buf, a->count);
|
42
|
+
}
|
43
|
+
static ssize_t my_write(int fd, const void *buf, size_t count)
|
44
|
+
{
|
45
|
+
struct write_args a;
|
46
|
+
ssize_t r;
|
47
|
+
|
48
|
+
a.fd = fd;
|
49
|
+
a.buf = buf;
|
50
|
+
a.count = count;
|
51
|
+
r = (ssize_t)rb_thread_io_blocking_region(ng_write, &a, fd);
|
52
|
+
|
53
|
+
return r;
|
54
|
+
}
|
55
|
+
# define stat(fd,buf) my_stat((fd),(buf))
|
56
|
+
# define fstat(fd,buf) my_fstat((fd),(buf))
|
57
|
+
# define write(fd,buf,count) my_write((fd),(buf),(count))
|
58
|
+
#endif
|
data/ext/clogger_ext/clogger.c
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
#include <time.h>
|
20
20
|
#include "ruby_1_9_compat.h"
|
21
21
|
#include "broken_system_compat.h"
|
22
|
+
#include "blocking_helpers.h"
|
22
23
|
|
23
24
|
/*
|
24
25
|
* Availability of a monotonic clock needs to be detected at runtime
|
@@ -607,6 +608,11 @@ static VALUE cwrite(struct clogger *c)
|
|
607
608
|
return Qnil;
|
608
609
|
}
|
609
610
|
|
611
|
+
static VALUE clogger_write(VALUE self)
|
612
|
+
{
|
613
|
+
return cwrite(clogger_get(self));
|
614
|
+
}
|
615
|
+
|
610
616
|
static void init_logger(struct clogger *c, VALUE path)
|
611
617
|
{
|
612
618
|
ID id;
|
@@ -686,18 +692,20 @@ static VALUE clogger_init(int argc, VALUE *argv, VALUE self)
|
|
686
692
|
return self;
|
687
693
|
}
|
688
694
|
|
689
|
-
static VALUE body_iter_i(VALUE str, VALUE
|
695
|
+
static VALUE body_iter_i(VALUE str, VALUE self)
|
690
696
|
{
|
691
|
-
|
697
|
+
struct clogger *c = clogger_get(self);
|
692
698
|
|
693
699
|
str = rb_obj_as_string(str);
|
694
|
-
|
700
|
+
c->body_bytes_sent += RSTRING_LEN(str);
|
695
701
|
|
696
702
|
return rb_yield(str);
|
697
703
|
}
|
698
704
|
|
699
|
-
static VALUE body_close(
|
705
|
+
static VALUE body_close(VALUE self)
|
700
706
|
{
|
707
|
+
struct clogger *c = clogger_get(self);
|
708
|
+
|
701
709
|
if (rb_respond_to(c->body, close_id))
|
702
710
|
return rb_funcall(c->body, close_id, 0);
|
703
711
|
return Qnil;
|
@@ -717,7 +725,7 @@ static VALUE clogger_each(VALUE self)
|
|
717
725
|
|
718
726
|
rb_need_block();
|
719
727
|
c->body_bytes_sent = 0;
|
720
|
-
rb_iterate(rb_each, c->body, body_iter_i,
|
728
|
+
rb_iterate(rb_each, c->body, body_iter_i, self);
|
721
729
|
|
722
730
|
return self;
|
723
731
|
}
|
@@ -732,9 +740,8 @@ static VALUE clogger_each(VALUE self)
|
|
732
740
|
*/
|
733
741
|
static VALUE clogger_close(VALUE self)
|
734
742
|
{
|
735
|
-
struct clogger *c = clogger_get(self);
|
736
743
|
|
737
|
-
return rb_ensure(body_close,
|
744
|
+
return rb_ensure(body_close, self, clogger_write, self);
|
738
745
|
}
|
739
746
|
|
740
747
|
/* :nodoc: */
|
@@ -881,23 +888,25 @@ static VALUE respond_to(VALUE self, VALUE method)
|
|
881
888
|
static VALUE to_path(VALUE self)
|
882
889
|
{
|
883
890
|
struct clogger *c = clogger_get(self);
|
884
|
-
VALUE path = rb_funcall(c->body, to_path_id, 0);
|
885
891
|
struct stat sb;
|
886
892
|
int rv;
|
887
|
-
|
888
|
-
const char *cpath = StringValuePtr(path);
|
893
|
+
VALUE path = rb_funcall(c->body, to_path_id, 0);
|
889
894
|
|
890
895
|
/* try to avoid an extra path lookup */
|
891
|
-
if (rb_respond_to(c->body, to_io_id))
|
896
|
+
if (rb_respond_to(c->body, to_io_id)) {
|
892
897
|
rv = fstat(my_fileno(c->body), &sb);
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
898
|
+
} else {
|
899
|
+
const char *cpath = StringValueCStr(path);
|
900
|
+
unsigned devfd;
|
901
|
+
/*
|
902
|
+
* Rainbows! can use "/dev/fd/%u" in to_path output to avoid
|
903
|
+
* extra open() syscalls, too.
|
904
|
+
*/
|
905
|
+
if (sscanf(cpath, "/dev/fd/%u", &devfd) == 1)
|
906
|
+
rv = fstat((int)devfd, &sb);
|
907
|
+
else
|
908
|
+
rv = stat(cpath, &sb);
|
909
|
+
}
|
901
910
|
|
902
911
|
/*
|
903
912
|
* calling this method implies the web server will bypass
|
data/ext/clogger_ext/extconf.rb
CHANGED
@@ -22,6 +22,8 @@ begin
|
|
22
22
|
have_func('localtime_r', 'time.h') or raise "localtime_r needed"
|
23
23
|
have_func('gmtime_r', 'time.h') or raise "gmtime_r needed"
|
24
24
|
have_func('rb_str_set_len', 'ruby.h')
|
25
|
+
have_func('rb_thread_blocking_region', 'ruby.h')
|
26
|
+
have_func('rb_thread_io_blocking_region', 'ruby.h')
|
25
27
|
dir_config('clogger_ext')
|
26
28
|
create_makefile('clogger_ext')
|
27
29
|
rescue Object => err
|
data/lib/clogger.rb
CHANGED
data/pkg.mk
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
RUBY = ruby
|
2
2
|
RAKE = rake
|
3
3
|
RSYNC = rsync
|
4
|
+
WRONGDOC = wrongdoc
|
4
5
|
|
5
6
|
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
|
6
7
|
@./GIT-VERSION-GEN
|
7
8
|
-include GIT-VERSION-FILE
|
8
9
|
-include local.mk
|
9
|
-
DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts
|
10
|
+
DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
|
10
11
|
RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
|
11
12
|
RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
|
12
13
|
lib := lib
|
@@ -43,26 +44,30 @@ $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
|
|
43
44
|
$(MAKE) -C $(@D)
|
44
45
|
lib := $(lib):$(ext_pfx)/$(ext)
|
45
46
|
build: $(ext_dl)
|
47
|
+
else
|
48
|
+
build:
|
46
49
|
endif
|
47
50
|
|
48
|
-
pkg_extra
|
51
|
+
pkg_extra += GIT-VERSION-FILE NEWS ChangeLog LATEST
|
49
52
|
ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
|
50
|
-
|
53
|
+
$(WRONGDOC) prepare
|
54
|
+
NEWS LATEST: ChangeLog
|
51
55
|
|
52
56
|
manifest:
|
53
57
|
$(RM) .manifest
|
54
58
|
$(MAKE) .manifest
|
55
59
|
|
56
|
-
.manifest:
|
60
|
+
.manifest: $(pkg_extra)
|
57
61
|
(git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
|
58
62
|
LC_ALL=C sort > $@+
|
59
63
|
cmp $@+ $@ || mv $@+ $@
|
60
64
|
$(RM) $@+
|
61
65
|
|
62
|
-
doc
|
63
|
-
find lib
|
66
|
+
doc:: .document .wrongdoc.yml $(pkg_extra)
|
67
|
+
-find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
|
68
|
+
-find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
|
64
69
|
$(RM) -r doc
|
65
|
-
|
70
|
+
$(WRONGDOC) all
|
66
71
|
install -m644 COPYING doc/COPYING
|
67
72
|
install -m644 $(shell grep '^[A-Z]' .document) doc/
|
68
73
|
|
@@ -75,10 +80,10 @@ release_changes := release_changes-$(VERSION)
|
|
75
80
|
release-notes: $(release_notes)
|
76
81
|
release-changes: $(release_changes)
|
77
82
|
$(release_changes):
|
78
|
-
|
83
|
+
$(WRONGDOC) release_changes > $@+
|
79
84
|
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
80
85
|
$(release_notes):
|
81
|
-
|
86
|
+
$(WRONGDOC) release_notes > $@+
|
82
87
|
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
83
88
|
|
84
89
|
# ensures we're actually on the tagged $(VERSION), only used for release
|
@@ -142,7 +147,7 @@ test_units := $(wildcard test/test_*.rb)
|
|
142
147
|
test: test-unit
|
143
148
|
test-unit: $(test_units)
|
144
149
|
$(test_units): build
|
145
|
-
$(RUBY) -I $(lib) $@
|
150
|
+
$(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
|
146
151
|
|
147
152
|
# this requires GNU coreutils variants
|
148
153
|
ifneq ($(RSYNC_DEST),)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 59
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- cloggers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-15 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- README
|
83
83
|
- Rakefile
|
84
84
|
- clogger.gemspec
|
85
|
+
- ext/clogger_ext/blocking_helpers.h
|
85
86
|
- ext/clogger_ext/broken_system_compat.h
|
86
87
|
- ext/clogger_ext/clogger.c
|
87
88
|
- ext/clogger_ext/extconf.rb
|
@@ -102,7 +103,7 @@ rdoc_options:
|
|
102
103
|
- -t
|
103
104
|
- \Clogger - configurable request logging for Rack
|
104
105
|
- -W
|
105
|
-
- http://
|
106
|
+
- http://bogomips.org/clogger.git/tree/%s
|
106
107
|
require_paths:
|
107
108
|
- lib
|
108
109
|
- ext
|
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
128
|
requirements: []
|
128
129
|
|
129
130
|
rubyforge_project: clogger
|
130
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.6.1
|
131
132
|
signing_key:
|
132
133
|
specification_version: 3
|
133
134
|
summary: configurable request logging for Rack
|