yell-adapters-syslog 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module Yell #:nodoc:
4
4
  module Adapters #:nodoc:
5
5
 
6
6
  class Syslog
7
- VERSION = "0.7.0"
7
+ VERSION = "0.8.0"
8
8
 
9
9
  end
10
10
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'syslog'
4
+
3
5
  module Yell #:nodoc:
4
6
  module Adapters #:nodoc:
5
7
 
@@ -10,15 +12,6 @@ module Yell #:nodoc:
10
12
  # `man syslog` to see the severities
11
13
  Severities = [7, 6, 4, 3, 2, 1]
12
14
 
13
- # Map Syslog severities to internal represenation
14
- # 'DEBUG' => 7
15
- # 'INFO' => 6
16
- # 'WARN' => 4
17
- # 'ERROR' => 3
18
- # 'FATAL' => 2
19
- # 'UNKNOWN' => 1
20
- SeverityMap = Hash[ *(Yell::Severities.zip(Severities).flatten) ]
21
-
22
15
  # Map Syslog options to internal representation
23
16
  OptionMap = {
24
17
  :cons => ::Syslog::LOG_CONS,
@@ -63,7 +56,7 @@ module Yell #:nodoc:
63
56
  end
64
57
 
65
58
  write do |event|
66
- stream.log( SeverityMap[event.level], clean(event.message) )
59
+ stream.log( Severities[event.level], clean(event.message) )
67
60
  end
68
61
 
69
62
  close do
@@ -21,10 +21,6 @@
21
21
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- module Yell #:nodoc:
25
- end
26
-
27
- require 'syslog'
28
24
  require 'yell'
29
25
 
30
26
  require File.dirname(__FILE__) + '/yell/adapters/syslog'
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Yell::Adapters::Syslog do
4
+ let( :event ) { Yell::Event.new( 1, "Hello World" ) }
5
+
4
6
  before do
5
7
  Syslog.close if Syslog.opened?
6
8
  end
@@ -9,18 +11,18 @@ describe Yell::Adapters::Syslog do
9
11
  let( :adapter ) { Yell::Adapters::Syslog.new }
10
12
 
11
13
  it "should call Syslog correctly" do
12
- mock( Syslog ).log( Yell::Adapters::Syslog::SeverityMap[subject], "Hello World" )
14
+ mock( Syslog ).log( Yell::Adapters::Syslog::Severities[subject], "Hello World" )
13
15
 
14
16
  adapter.write Yell::Event.new( subject, "Hello World" )
15
17
  end
16
18
  end
17
19
 
18
- it_behaves_like( "a Syslog adapter" ) { subject { 'DEBUG' } }
19
- it_behaves_like( "a Syslog adapter" ) { subject { 'INFO' } }
20
- it_behaves_like( "a Syslog adapter" ) { subject { 'WARN' } }
21
- it_behaves_like( "a Syslog adapter" ) { subject { 'ERROR' } }
22
- it_behaves_like( "a Syslog adapter" ) { subject { 'FATAL' } }
23
- it_behaves_like( "a Syslog adapter" ) { subject { 'UNKNOWN' } }
20
+ it_behaves_like( "a Syslog adapter" ) { subject { 0 } } # debug
21
+ it_behaves_like( "a Syslog adapter" ) { subject { 1 } } # info
22
+ it_behaves_like( "a Syslog adapter" ) { subject { 2 } } # warn
23
+ it_behaves_like( "a Syslog adapter" ) { subject { 3 } } # error
24
+ it_behaves_like( "a Syslog adapter" ) { subject { 4 } } # fatal
25
+ it_behaves_like( "a Syslog adapter" ) { subject { 5 } } # unknown
24
26
 
25
27
  context "a new Yell::Adapters::Syslog instance" do
26
28
  subject { Yell::Adapters::Syslog.new }
@@ -76,7 +78,7 @@ describe Yell::Adapters::Syslog do
76
78
  mock.proxy( Syslog ).open( "my ident", anything, anything )
77
79
 
78
80
  subject.ident = "my ident"
79
- subject.write Yell::Event.new("INFO", "Hello World")
81
+ subject.write event
80
82
  end
81
83
  end
82
84
 
@@ -87,14 +89,14 @@ describe Yell::Adapters::Syslog do
87
89
  mock.proxy( Syslog ).open( anything, Syslog::LOG_NDELAY, anything )
88
90
 
89
91
  subject.options = :ndelay
90
- subject.write Yell::Event.new("INFO", "Hello World")
92
+ subject.write event
91
93
  end
92
94
 
93
95
  it "should work with multiple params" do
94
96
  mock.proxy( Syslog ).open( anything, Syslog::LOG_PID|Syslog::LOG_NDELAY, anything )
95
97
 
96
98
  subject.options = [:pid, :ndelay]
97
- subject.write Yell::Event.new("INFO", "Hello World")
99
+ subject.write event
98
100
  end
99
101
  end
100
102
 
@@ -105,14 +107,14 @@ describe Yell::Adapters::Syslog do
105
107
  mock.proxy( Syslog ).open( anything, anything, Syslog::LOG_USER )
106
108
 
107
109
  subject.facility = :user
108
- subject.write Yell::Event.new("INFO", "Hello World")
110
+ subject.write event
109
111
  end
110
112
 
111
113
  it "should work with multiple params" do
112
114
  mock.proxy( Syslog ).open( anything, anything, Syslog::LOG_DAEMON|Syslog::LOG_USER )
113
115
 
114
116
  subject.facility = [:daemon, :user]
115
- subject.write Yell::Event.new("INFO", "Hello World")
117
+ subject.write event
116
118
  end
117
119
  end
118
120
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency "yell", "~> 0.6"
21
+ s.add_runtime_dependency "yell", "~> 0.8.x"
22
22
  s.add_development_dependency "rspec"
23
23
  s.add_development_dependency "rr"
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yell-adapters-syslog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-21 00:00:00.000000000 Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yell
16
- requirement: &70303402799860 !ruby/object:Gem::Requirement
16
+ requirement: &70362241216920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.6'
21
+ version: 0.8.x
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70303402799860
24
+ version_requirements: *70362241216920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70303402799460 !ruby/object:Gem::Requirement
27
+ requirement: &70362241216520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70303402799460
35
+ version_requirements: *70362241216520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rr
38
- requirement: &70303402799000 !ruby/object:Gem::Requirement
38
+ requirement: &70362239203280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70303402799000
46
+ version_requirements: *70362239203280
47
47
  description: Syslog adapter for Yell
48
48
  email:
49
49
  executables: []