madvertise-logging 1.0.0.rc2 → 1.0.0.rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -319,17 +319,36 @@ module Madvertise
319
319
  #
320
320
  class Formatter
321
321
 
322
- @format = "%s %s(%d) [%s] %s\n"
322
+ @format = "%{time} %{progname}(%{pid}) [%{severity}] %{msg}\n"
323
+ @time_format = "%Y-%m-%d %H:%M:%S.%N"
323
324
 
324
325
  class << self
325
326
  # Format string for log messages.
326
327
  attr_accessor :format
328
+
329
+ # Format string for timestamps in log messages.
330
+ attr_accessor :time_format
327
331
  end
328
332
 
333
+ RUBY2SYSLOG = {
334
+ :debug => 7,
335
+ :info => 6,
336
+ :warn => 4,
337
+ :error => 3,
338
+ :fatal => 2,
339
+ :unknown => 3,
340
+ }
341
+
329
342
  # @private
330
343
  def call(severity, time, progname, msg)
331
- time = time.strftime("%Y-%m-%d %H:%M:%S.%N")
332
- self.class.format % [time, progname, $$, severity, msg.to_s]
344
+ self.class.format % {
345
+ :time => time.strftime(self.class.time_format),
346
+ :progname => progname,
347
+ :pid => $$,
348
+ :severity => severity,
349
+ :syslog_severity => RUBY2SYSLOG[severity.downcase.to_sym],
350
+ :msg => msg.to_s,
351
+ }
333
352
  end
334
353
  end
335
354
 
@@ -1,6 +1,6 @@
1
1
  module Madvertise
2
2
  module Logging
3
3
  # @private
4
- VERSION = "1.0.0.rc2"
4
+ VERSION = "1.0.0.rc3"
5
5
  end
6
6
  end
@@ -85,12 +85,12 @@ describe ImprovedLogger do
85
85
 
86
86
  it "logs an exception object" do
87
87
  logger.exception(exc)
88
- subject.last[:message].should == "exception class=RuntimeError reason=\"Test error\" message= backtrace=\"['/home/jdoe/app/libexec/app.rb:1:in `foo'']\""
88
+ subject.last[:message].should match(%r{exception class=RuntimeError reason=\"Test error\" message= backtrace=\"\['/home/jdoe/app/libexec/app\.rb:1:in `foo''\]\"})
89
89
  end
90
90
 
91
91
  it "logs an exception object and prefix" do
92
92
  logger.exception(exc, "app failed to foo")
93
- subject.last[:message].should == "exception class=RuntimeError reason=\"Test error\" message=\"app failed to foo\" backtrace=\"['/home/jdoe/app/libexec/app.rb:1:in `foo'']\""
93
+ subject.last[:message].should match(%r{exception class=RuntimeError reason=\"Test error\" message=\"app failed to foo\" backtrace=\"\['/home/jdoe/app/libexec/app\.rb:1:in `foo''\]\"})
94
94
  end
95
95
  end
96
96
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madvertise-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Advanced logging classes with buffer backend, transactions, multi logger,
15
15
  etc
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  segments:
60
60
  - 0
61
- hash: -3712847879214537117
61
+ hash: 4043118635048299053
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements: