clogger 0.2.0 → 0.3.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=v0.2.0.GIT
4
+ DEF_VER=v0.3.0.GIT
5
5
 
6
6
  LF='
7
7
  '
data/GNUmakefile CHANGED
@@ -96,7 +96,7 @@ $(release_changes):
96
96
  $(RAKE) -s release_changes > $@+
97
97
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
98
98
  $(release_notes):
99
- GIT_URL=$(GIT_URL) $(RUBY) -s release_notes > $@+
99
+ GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
100
100
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
101
101
 
102
102
  # ensures we're actually on the tagged $(VERSION), only used for release
data/README CHANGED
@@ -20,9 +20,9 @@ is customizable so you can specify exactly which fields to log.
20
20
  " (double quote)
21
21
  all bytes in the range of \x00-\x1F
22
22
 
23
- * multi-instance capable and reentrant. You can use Clogger in a
24
- multi-threaded server, and even multiple Cloggers logging to
25
- different locations and different formats in the same process.
23
+ * multi-instance capable and (optionally) reentrant. You can use
24
+ Clogger in a multi-threaded server, and even multiple Cloggers logging
25
+ to different locations and different formats in the same process.
26
26
 
27
27
  == SYNOPSIS
28
28
 
@@ -31,7 +31,8 @@ Clogger may be loaded as Rack middleware in your config.ru:
31
31
  require "clogger"
32
32
  use Clogger,
33
33
  :format => Clogger::Format::Combined,
34
- :logger => ::File.open("/path/to/log", "ab")
34
+ :logger => ::File.open("/path/to/log", "ab"),
35
+ :reentrant => true
35
36
  run YourApplication.new
36
37
 
37
38
  If you're using Rails 2.3.x or later, in your config/environment.rb
@@ -39,7 +40,8 @@ somewhere inside the "Rails::Initializer.run do |config|" block:
39
40
 
40
41
  config.middleware.use 'Clogger',
41
42
  :format => Clogger::Format::Combined,
42
- :logger => ::File.open("/path/to/log", "ab")
43
+ :logger => ::File.open("/path/to/log", "ab"),
44
+ :reentrant => false
43
45
 
44
46
  == VARIABLES
45
47
 
data/Rakefile CHANGED
@@ -44,6 +44,7 @@ def tags
44
44
  end
45
45
 
46
46
  cgit_url = "http://git.bogomips.org/cgit/clogger.git"
47
+ git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/clogger.git'
47
48
 
48
49
  desc 'prints news as an Atom feed'
49
50
  task :news_atom do
@@ -104,8 +105,6 @@ desc "print release notes for Rubyforge"
104
105
  task :release_notes do
105
106
  require 'rubygems'
106
107
 
107
- git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/clogger.git'
108
-
109
108
  spec = Gem::Specification.load('clogger.gemspec')
110
109
  puts spec.description.strip
111
110
  puts ""
@@ -145,7 +144,7 @@ task :raa_update do
145
144
  :category_minor => 'Rack',
146
145
  :url => s.homepage,
147
146
  :download => 'http://rubyforge.org/frs/?group_id=8896',
148
- :license => 'LGPLv3',
147
+ :license => 'LGPL',
149
148
  :description_style => 'Plain',
150
149
  :description => desc,
151
150
  :pass => password,
@@ -599,6 +599,19 @@ static VALUE clogger_init(int argc, VALUE *argv, VALUE self)
599
599
  tmp = rb_hash_aref(o, ID2SYM(rb_intern("format")));
600
600
  if (!NIL_P(tmp))
601
601
  fmt = tmp;
602
+
603
+ tmp = rb_hash_aref(o, ID2SYM(rb_intern("reentrant")));
604
+ switch (TYPE(tmp)) {
605
+ case T_TRUE:
606
+ c->reentrant = 1;
607
+ break;
608
+ case T_FALSE:
609
+ c->reentrant = 0;
610
+ case T_NIL:
611
+ break;
612
+ default:
613
+ rb_raise(rb_eArgError, ":reentrant must be boolean");
614
+ }
602
615
  }
603
616
 
604
617
  init_buffers(c);
data/lib/clogger.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: binary -*-
2
2
  class Clogger
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
 
5
5
  OP_LITERAL = 0
6
6
  OP_REQUEST = 1
data/lib/clogger/pure.rb CHANGED
@@ -13,7 +13,7 @@ class Clogger
13
13
  (@logger.sync = true) rescue nil
14
14
  @fmt_ops = compile_format(opts[:format] || Format::Common, opts)
15
15
  @wrap_body = need_wrap_body?(@fmt_ops)
16
- @reentrant = nil
16
+ @reentrant = opts[:reentrant]
17
17
  @need_resp = need_response_headers?(@fmt_ops)
18
18
  @body_bytes_sent = 0
19
19
  end
@@ -28,7 +28,7 @@ class Clogger
28
28
  status, headers, body = resp
29
29
  headers = Rack::Utils::HeaderHash.new(headers) if @need_resp
30
30
  if @wrap_body
31
- @reentrant = env['rack.multithread']
31
+ @reentrant = env['rack.multithread'] if @reentrant.nil?
32
32
  @env, @status, @headers, @body = env, status, headers, body
33
33
  return [ status, headers, @reentrant ? self.dup : self ]
34
34
  end
data/test/test_clogger.rb CHANGED
@@ -545,4 +545,46 @@ class TestClogger < Test::Unit::TestCase
545
545
  assert_equal :foo, body.close
546
546
  end
547
547
 
548
+ def test_clogger_auto_reentrant_true
549
+ s = ''
550
+ body = []
551
+ app = lambda { |env| [302, [ %w(a) ], body ] }
552
+ cl = Clogger.new(app, :logger => s, :format => "$request_time")
553
+ @req['rack.multithread'] = true
554
+ status, headers, body = cl.call(@req)
555
+ assert cl.reentrant?
556
+ end
557
+
558
+ def test_clogger_auto_reentrant_false
559
+ s = ''
560
+ body = []
561
+ app = lambda { |env| [302, [ %w(a) ], body ] }
562
+ cl = Clogger.new(app, :logger => s, :format => "$request_time")
563
+ @req['rack.multithread'] = false
564
+ status, headers, body = cl.call(@req)
565
+ assert ! cl.reentrant?
566
+ end
567
+
568
+ def test_clogger_auto_reentrant_forced_true
569
+ s = ''
570
+ body = []
571
+ app = lambda { |env| [302, [ %w(a) ], body ] }
572
+ o = { :logger => s, :format => "$request_time", :reentrant => true }
573
+ cl = Clogger.new(app, o)
574
+ @req['rack.multithread'] = false
575
+ status, headers, body = cl.call(@req)
576
+ assert cl.reentrant?
577
+ end
578
+
579
+ def test_clogger_auto_reentrant_forced_false
580
+ s = ''
581
+ body = []
582
+ app = lambda { |env| [302, [ %w(a) ], body ] }
583
+ o = { :logger => s, :format => "$request_time", :reentrant => false }
584
+ cl = Clogger.new(app, o)
585
+ @req['rack.multithread'] = true
586
+ status, headers, body = cl.call(@req)
587
+ assert ! cl.reentrant?
588
+ end
589
+
548
590
  end
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: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloggers
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-07 00:00:00 +00:00
12
+ date: 2010-02-09 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency