rack-common_logger-fluent 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -12,13 +12,14 @@ rack middleware for writing access log to fluentd.
12
12
  use Rack::CommonLogger::Fluent, 'myapp', logger
13
13
 
14
14
  # if you want to customize format
15
- use Rack::CommonLogger::Fluent, 'myapp', logger do |info|
16
- result = {}
17
-
18
- # ...
15
+ format = lambda do |info|
16
+ result = Rack::CommonLogger::Fluent.default_format
17
+ # customize format.
18
+ result["xxxxxx"] = info[:env]["appx.xxxxxx"]
19
19
 
20
20
  result
21
21
  end
22
+ use Rack::CommonLogger::Fluent, 'myapp', logger, format
22
23
 
23
24
  == WARN
24
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -16,26 +16,26 @@ module Rack
16
16
  # # #=> 2012-05-12T17:56:50+09:00 myapp.access {"remote_addr":"127.0.0.1","date":"2012-05-12T17:56:50+09:00","request_method":"GET","path_info":"/","query_string":"?body=1","http_version":"HTTP/1.1","http_status":304,"user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19","content_type":null,"content_length":null,"runtime":0.007976}
17
17
  #
18
18
  # # if you want to customize format
19
- # use Rack::CommonLogger::Fluent, 'myapp', logger do |info|
20
- # result = {}
21
- #
19
+ # format = lambda do |info|
20
+ # result = Rack::CommonLogger::Fluent.default_format
21
+ # result["xxxxxx"] = info[:env]["appx.xxxxxx"]
22
22
  # # ...
23
23
  #
24
24
  # result
25
25
  # end
26
- #
26
+ # use Rack::CommonLogger::Fluent, 'myapp', logger, format
27
27
  #
28
28
  class Fluent
29
29
  # tag is Fluent::Logger's tag for access log.
30
30
  # +logger+ should implement post(+tag+, +message) method. logger is a Fluent::Logger::FluentLogger object.
31
31
  # +format+ is block that take Hash that has +env+(Rack's env), +status+, +header+, +now+, +runtime+, and should return Hash that contain access_log element.
32
32
  # +format+ is optional and use +default_format+ as default.
33
- def initialize(app, tag, logger=nil, &format)
33
+ def initialize(app, tag, logger=nil, format=nil)
34
34
  @app = app
35
35
  @logger = logger || ::Fluent::Logger::FluentLogger.new(nil, :host => 'localhost', :port => 24224)
36
36
  @tag = tag
37
37
  @format = format || lambda do |info|
38
- self.default_format(info)
38
+ self.class.default_format(info)
39
39
  end
40
40
  end
41
41
 
@@ -71,7 +71,7 @@ module Rack
71
71
  # content_length: Content-Length response header.(Fixnum)
72
72
  # runtime: seconds of application running. (Float)
73
73
  #
74
- def default_format(info)
74
+ def self.default_format(info)
75
75
  hash = {}
76
76
 
77
77
  hash["hostname"] = info[:env]["HTTP_HOST"] || info[:env]["SERVER_NAME"]
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rack-common_logger-fluent"
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Keiji, Yoshimi"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-common_logger-fluent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -4004731729266765288
145
+ hash: -380975601982097249
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements: