logjam_agent 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,15 +34,12 @@ module LogjamAgent
34
34
  def add(severity, message = nil, progname = nil, &block)
35
35
  return if @level > severity
36
36
  message = (message || (block && block.call) || '').to_s
37
- # If a newline is necessary then create a new message ending with a newline.
38
- # Ensures that the original message is not mutated.
39
- message = "#{message}\n" unless message[-1] == ?\n
40
37
  time = Time.now
41
- buffer << formatter.call(severity, time, progname, message)
38
+ buffer << formatter.call(severity, time, progname, message) << "\n"
42
39
  auto_flush
43
40
  if request = self.request
44
41
  # puts "adding line to request"
45
- request.add_line(severity, time, message[0..-2])
42
+ request.add_line(severity, time, message)
46
43
  end
47
44
  message
48
45
  end
@@ -20,20 +20,20 @@ module LogjamAgent
20
20
  timestamp.strftime("%b %d %H:%M:%S.#{timestamp.usec}")
21
21
  end
22
22
 
23
- def format_msg(msg)
24
- "#{msg}".sub(/^[\s\n]+/, '').sub(/[\s\n]+$/,"\n")
23
+ def format_message(msg)
24
+ msg.strip
25
25
  end
26
26
 
27
27
  def call(severity, timestamp, progname, msg)
28
- "#{format_severity(severity)} #{format_time(timestamp)} #{@hostname} #{progname||@app_name}[#{$$}]#{render_extra_attributes}: #{format_msg(msg)}"
28
+ "#{format_severity(severity)} #{format_time(timestamp)} #{@hostname} #{progname||@app_name}[#{$$}]#{render_extra_attributes}: #{format_message(msg)}"
29
29
  end
30
30
 
31
31
  def render_extra_attributes
32
- (self.extra_attributes||[]).map{|key, value| " #{key}[#{value}]"}
32
+ (@extra_attributes || []).map{|key, value| " #{key}[#{value}]"}.join
33
33
  end
34
34
 
35
35
  def add_extra_attributes(attributes)
36
- (self.extra_attributes ||= []).concat(attributes)
36
+ (@extra_attributes ||= []).concat(attributes)
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
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-04 00:00:00 +02:00
18
+ date: 2011-09-05 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency