clogger 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v1.1.0.GIT
4
+ DEF_VER=v1.2.0
5
5
 
6
6
  LF='
7
7
  '
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
- and supported under MRI 1.8.7, 1.9.1, 1.9.2 and Rubinius.
27
+ and supported under MRI 1.8.7, 1.9, 2.0 and Rubinius.
28
28
 
29
29
  == SYNOPSIS
30
30
 
@@ -33,7 +33,7 @@ is customizable so you can specify exactly which fields to log.
33
33
  # ENV['CLOGGER_PURE'] = '1' # uncomment to disable C extension
34
34
  require "clogger"
35
35
  use Clogger,
36
- :format => Clogger::Format::Combined,
36
+ :format => :Combined,
37
37
  :path => "/path/to/log",
38
38
  :reentrant => true
39
39
  run YourApplication.new
@@ -42,7 +42,7 @@ If you're using Rails 2.3.x or later, in your config/environment.rb
42
42
  somewhere inside the "Rails::Initializer.run do |config|" block:
43
43
 
44
44
  config.middleware.use 'Clogger',
45
- :format => Clogger::Format::Combined,
45
+ :format => :Combined,
46
46
  :path => "/path/to/log",
47
47
  :reentrant => false
48
48
 
@@ -119,6 +119,7 @@ struct clogger {
119
119
  int reentrant; /* tri-state, -1:auto, 1/0 true/false */
120
120
  };
121
121
 
122
+ static ID write_id;
122
123
  static ID ltlt_id;
123
124
  static ID call_id;
124
125
  static ID each_id;
@@ -687,9 +688,12 @@ static VALUE cwrite(struct clogger *c)
687
688
  } else {
688
689
  VALUE logger = c->logger;
689
690
 
690
- if (NIL_P(logger))
691
+ if (NIL_P(logger)) {
691
692
  logger = rb_hash_aref(c->env, g_rack_errors);
692
- rb_funcall(logger, ltlt_id, 1, dst);
693
+ rb_funcall(logger, write_id, 1, dst);
694
+ } else {
695
+ rb_funcall(logger, ltlt_id, 1, dst);
696
+ }
693
697
  }
694
698
 
695
699
  return Qnil;
@@ -1036,6 +1040,7 @@ void Init_clogger_ext(void)
1036
1040
 
1037
1041
  check_clock();
1038
1042
 
1043
+ write_id = rb_intern("write");
1039
1044
  ltlt_id = rb_intern("<<");
1040
1045
  call_id = rb_intern("call");
1041
1046
  each_id = rb_intern("each");
@@ -2,11 +2,6 @@ begin
2
2
  require 'mkmf'
3
3
  $CPPFLAGS += " -D_BSD_SOURCE=1 "
4
4
 
5
- # XXX let me know if this works for you...
6
- if ! defined?(RUBY_VERSION) || RUBY_VERSION !~ /\A1\.[89]\./
7
- raise "Invalid RUBY_VERSION for C extension"
8
- end
9
-
10
5
  have_header('ruby.h') or raise "ruby.h header not found!"
11
6
 
12
7
  if have_header('fcntl.h')
data/lib/clogger/pure.rb CHANGED
@@ -161,7 +161,7 @@ private
161
161
  end
162
162
 
163
163
  def log(env, status, headers)
164
- (@logger || env['rack.errors']) << @fmt_ops.map { |op|
164
+ str = @fmt_ops.map { |op|
165
165
  case op[0]
166
166
  when OP_LITERAL; op[1]
167
167
  when OP_REQUEST; byte_xs(env[op[1]] || "-")
@@ -182,5 +182,13 @@ private
182
182
  raise "EDOOFUS #{op.inspect}"
183
183
  end
184
184
  }.join('')
185
+
186
+ l = @logger
187
+ if l
188
+ l << str
189
+ else
190
+ env['rack.errors'].write(str)
191
+ end
192
+ nil
185
193
  end
186
194
  end
data/pkg.mk CHANGED
@@ -69,7 +69,7 @@ doc:: .document .wrongdoc.yml $(pkg_extra)
69
69
  $(RM) -r doc
70
70
  $(WRONGDOC) all
71
71
  install -m644 COPYING doc/COPYING
72
- install -m644 $(shell grep '^[A-Z]' .document) doc/
72
+ install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
73
73
 
74
74
  ifneq ($(VERSION),)
75
75
  pkggem := pkg/$(rfpackage)-$(VERSION).gem
@@ -167,5 +167,9 @@ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
167
167
  doc_gz:
168
168
  for i in $(docs); do \
169
169
  gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
170
+ check-warnings:
171
+ @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
172
+ do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
170
173
 
171
174
  .PHONY: all .FORCE-GIT-VERSION-FILE doc test $(test_units) manifest
175
+ .PHONY: check-warnings
data/test/test_clogger.rb CHANGED
@@ -481,6 +481,26 @@ class TestClogger < Test::Unit::TestCase
481
481
  assert r.object_id != body.object_id
482
482
  end
483
483
 
484
+ # Rack::BodyProxy does this thing with method_missing
485
+ # This test fails under MRI 1.9.1 and 1.9.2, but works under 1.9.3
486
+ def test_each_with_external_block
487
+ foo = Object.new
488
+ foo.instance_variable_set(:@body, ["BodyProxy"])
489
+ def foo.method_missing(*args, &block)
490
+ @body.__send__(*args, &block)
491
+ end
492
+ app = lambda { |env| [302, [], foo] }
493
+ str = StringIO.new
494
+ cl = Clogger.new(app, :logger => str, :format => '$body_bytes_sent')
495
+ r = nil
496
+ assert_nothing_raised { r = cl.call(@req) }
497
+ body = []
498
+ r[2].each { |x| body << x }
499
+ r[2].close
500
+ assert_equal %w(BodyProxy), body
501
+ assert_equal "9\n", str.string
502
+ end
503
+
484
504
  def test_http_09_request
485
505
  str = StringIO.new
486
506
  app = lambda { |env| [302, [ %w(a) ], []] }
@@ -817,4 +837,21 @@ class TestClogger < Test::Unit::TestCase
817
837
  expect = "\"GET http://example.com/hello?goodbye=true HTTP/1.0\"\n"
818
838
  assert_equal [ expect ], s
819
839
  end
840
+
841
+ def test_lint_error_wrapper
842
+ require 'rack/lobster'
843
+ @req["SERVER_NAME"] = "FOO"
844
+ @req["SERVER_PORT"] = "666"
845
+ @req["rack.version"] = [1,1]
846
+ @req["rack.multithread"] = true
847
+ @req["rack.multiprocess"] = true
848
+ @req["rack.run_once"] = false
849
+ app = Rack::ContentLength.new(Rack::ContentType.new(Rack::Lobster.new))
850
+ cl = Clogger.new(app, :format => :Combined)
851
+ @req["rack.errors"] = err = StringIO.new
852
+ status, headers, body = r = Rack::Lint.new(cl).call(@req)
853
+ body.each { |x| assert_kind_of String, x.to_str }
854
+ body.close # might raise here
855
+ assert_match(%r{GET /hello}, err.string)
856
+ end
820
857
  end
metadata CHANGED
@@ -1,61 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: clogger
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 0
10
- version: 1.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - cloggers
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-06 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rack
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">"
27
- - !ruby/object:Gem::Version
28
- hash: 25
29
- segments:
30
- - 0
31
- - 9
32
- version: "0.9"
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '0.9'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: wrongdoc
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
- requirements:
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - !ruby/object:Gem::Dependency
31
+ name: wrongdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
41
35
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 15
44
- segments:
45
- - 1
46
- - 0
47
- version: "1.0"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
48
38
  type: :development
49
- version_requirements: *id002
50
- description: |-
51
- \Clogger is Rack middleware for logging HTTP requests. The log format
52
- is customizable so you can specify exactly which fields to log.
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ description: ! '\Clogger is Rack middleware for logging HTTP requests. The log format
47
+
48
+ is customizable so you can specify exactly which fields to log.'
53
49
  email: clogger@librelist.org
54
50
  executables: []
55
-
56
- extensions:
51
+ extensions:
57
52
  - ext/clogger_ext/extconf.rb
58
- extra_rdoc_files:
53
+ extra_rdoc_files:
59
54
  - README
60
55
  - NEWS
61
56
  - ChangeLog
@@ -65,7 +60,7 @@ extra_rdoc_files:
65
60
  - ext/clogger_ext/clogger.c
66
61
  - LICENSE
67
62
  - LATEST
68
- files:
63
+ files:
69
64
  - .document
70
65
  - .gitignore
71
66
  - .manifest
@@ -95,41 +90,33 @@ files:
95
90
  - test/test_clogger_to_path.rb
96
91
  homepage: http://clogger.rubyforge.org/
97
92
  licenses: []
98
-
99
93
  post_install_message:
100
- rdoc_options:
94
+ rdoc_options:
101
95
  - -t
102
96
  - \Clogger - configurable request logging for Rack
103
97
  - -W
104
98
  - http://bogomips.org/clogger.git/tree/%s
105
- require_paths:
99
+ require_paths:
106
100
  - lib
107
101
  - ext
108
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
109
103
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
117
- required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
109
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
126
114
  requirements: []
127
-
128
115
  rubyforge_project: clogger
129
- rubygems_version: 1.8.11
116
+ rubygems_version: 1.8.23
130
117
  signing_key:
131
118
  specification_version: 3
132
119
  summary: configurable request logging for Rack
133
- test_files:
120
+ test_files:
134
121
  - test/test_clogger.rb
135
122
  - test/test_clogger_to_path.rb