fluent-logger 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ Release 0.4.1 - 2011/11/07
3
+
4
+ * added Logger#post_with_time(tag, map, time)
5
+ * Logger#post(tag, map, time=Time.now) -> Logger#post(tag, map)
6
+ * FluentLogger supports :debug=>true option to write all events to STDERR
7
+
8
+
2
9
  Release 0.4.0 - 2011/11/05
3
10
 
4
11
  * Wait before reconnecting to fluentd to prevent burst
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -48,8 +48,12 @@ module Logger
48
48
  end
49
49
  end
50
50
 
51
- def self.post(tag, map, time=nil)
52
- @@default_logger.post(tag, map, time)
51
+ def self.post(tag, map)
52
+ @@default_logger.post(tag, map)
53
+ end
54
+
55
+ def self.post_with_time(tag, map, time)
56
+ @@default_logger.post_with_time(tag, map, time)
53
57
  end
54
58
 
55
59
  def self.default
@@ -81,7 +81,13 @@ class FluentLogger < LoggerBase
81
81
  @connect_error_history = []
82
82
 
83
83
  @limit = options[:buffer_limit] || BUFFER_LIMIT
84
+
84
85
  @logger = options[:logger] || ::Logger.new(STDERR)
86
+ if options[:debug]
87
+ @logger.level = ::Logger::DEBUG
88
+ else
89
+ @logger.level = ::Logger::INFO
90
+ end
85
91
 
86
92
  begin
87
93
  connect!
@@ -93,8 +99,8 @@ class FluentLogger < LoggerBase
93
99
 
94
100
  attr_accessor :limit, :logger
95
101
 
96
- def post(tag, map, time=nil)
97
- time ||= Time.now
102
+ def post_with_time(tag, map, time)
103
+ @logger.debug { "event: #{tag} #{map.to_json}" rescue nil }
98
104
  tag = "#{@tag_prefix}.#{tag}" if @tag_prefix
99
105
  write [tag, time.to_i, map]
100
106
  end
@@ -23,7 +23,11 @@ class LoggerBase
23
23
  Fluent::Logger.open(self, *args, &block)
24
24
  end
25
25
 
26
- #def post(tag, map, time=nil)
26
+ def post(tag, map)
27
+ post_with_time(tag, map, Time.now)
28
+ end
29
+
30
+ #def post_with_time(tag, map)
27
31
  #end
28
32
 
29
33
  #def close(map)
@@ -19,7 +19,7 @@ module Fluent
19
19
  module Logger
20
20
 
21
21
  class NullLogger < LoggerBase
22
- def post(tag, map, time=nil)
22
+ def post_with_time(tag, map, time)
23
23
  false
24
24
  end
25
25
  end
@@ -27,7 +27,7 @@ class TestLogger < LoggerBase
27
27
  attr_accessor :max
28
28
  attr_reader :queue
29
29
 
30
- def post(tag, map, time=nil)
30
+ def post_with_time(tag, map, time)
31
31
  while @queue.size > @max-1
32
32
  @queue.shift
33
33
  end
@@ -24,8 +24,7 @@ class TextLogger < LoggerBase
24
24
  @time_format = "%b %e %H:%M:%S"
25
25
  end
26
26
 
27
- def post(tag, map, time=nil)
28
- time ||= Time.now
27
+ def post_with_time(tag, map, time)
29
28
  a = [time.strftime(@time_format), " ", tag, ":"]
30
29
  map.each_pair {|k,v|
31
30
  a << " #{k}="
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Logger
3
3
 
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
 
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-04 00:00:00.000000000Z
12
+ date: 2011-11-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
16
- requirement: &70346070861020 !ruby/object:Gem::Requirement
16
+ requirement: &70207037595840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70346070861020
24
+ version_requirements: *70207037595840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: msgpack
27
- requirement: &70346070860420 !ruby/object:Gem::Requirement
27
+ requirement: &70207037595300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70346070860420
35
+ version_requirements: *70207037595300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70346070859840 !ruby/object:Gem::Requirement
38
+ requirement: &70207037594800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70346070859840
46
+ version_requirements: *70207037594800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70346070859260 !ruby/object:Gem::Requirement
49
+ requirement: &70207037594340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.7.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70346070859260
57
+ version_requirements: *70207037594340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70346070858660 !ruby/object:Gem::Requirement
60
+ requirement: &70207037593860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.5.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70346070858660
68
+ version_requirements: *70207037593860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: timecop
71
- requirement: &70346070858200 !ruby/object:Gem::Requirement
71
+ requirement: &70207037593340 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.3.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70346070858200
79
+ version_requirements: *70207037593340
80
80
  description: fluent logger for ruby
81
81
  email: frsyuki@gmail.com
82
82
  executables: []
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: 675212802163774553
129
+ hash: 3162457063244932466
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  none: false
132
132
  requirements:
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: 675212802163774553
138
+ hash: 3162457063244932466
139
139
  requirements: []
140
140
  rubyforge_project:
141
141
  rubygems_version: 1.8.10