logjam_agent 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,9 +6,10 @@ module LogjamAgent
6
6
  def initialize
7
7
  @hostname = Socket.gethostname.split('.').first
8
8
  @app_name = "rails"
9
+ @attributes = []
9
10
  end
10
11
 
11
- attr_accessor :extra_attributes
12
+ attr_accessor :attributes
12
13
 
13
14
  SEV_LABEL = Logger::SEV_LABEL.map{|sev| "%-5s" % sev}
14
15
 
@@ -25,15 +26,19 @@ module LogjamAgent
25
26
  end
26
27
 
27
28
  def call(severity, timestamp, progname, msg)
28
- "#{format_severity(severity)} #{format_time(timestamp)} #{@hostname} #{progname||@app_name}[#{$$}]#{render_extra_attributes}: #{format_message(msg)}"
29
+ "#{format_severity(severity)} #{format_time(timestamp)} #{@hostname} #{progname||@app_name}[#{$$}]#{render_attributes}: #{format_message(msg)}"
29
30
  end
30
31
 
31
- def render_extra_attributes
32
- (@extra_attributes || []).map{|key, value| " #{key}[#{value}]"}.join
32
+ def render_attributes
33
+ @attributes.map{|key, value| " #{key}[#{value}]"}.join
33
34
  end
34
35
 
35
- def add_extra_attributes(attributes)
36
- (@extra_attributes ||= []).concat(attributes)
36
+ def set_attribute(name, value)
37
+ if attribute = @attributes.detect{|n,v| n == name}
38
+ attribute[1] = value
39
+ else
40
+ @attributes << [name, value]
41
+ end
37
42
  end
38
43
  end
39
44
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 4
10
- version: 0.2.4
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-25 00:00:00 +02:00
18
+ date: 2011-10-06 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency