yell-adapters-syslog 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
- Yell Adapters Syslog - Syslog Adapter for Your Extensible Logging Library
1
+ Syslog Adapter for Yell - Your Extensible Logging Library
2
2
 
3
3
  If you are not yet familiar with **Yell - Your Extensible Logging Library**
4
4
  check out the githup project under https://github.com/rudionrails/yell or jump
5
5
  directly into the Yell wiki at https://github.com/rudionrails/yell/wiki.
6
6
 
7
+ [![Build Status](https://secure.travis-ci.org/rudionrails/yell-adapters-syslog.png?branch=master)](http://travis-ci.org/rudionrails/yell-adapters-syslog)
8
+
9
+ The Syslog adapter for Yell works and is tested with ruby 1.8.7, 1.9.x, jruby 1.8 and 1.9 mode, rubinius 1.8 and 1.9 as well as ree.
10
+
7
11
  ## Installation
8
12
 
9
13
  System wide:
@@ -4,7 +4,7 @@ module Yell #:nodoc:
4
4
  module Adapters #:nodoc:
5
5
 
6
6
  class Syslog
7
- VERSION = "0.4.1"
7
+ VERSION = "0.6.0"
8
8
 
9
9
  end
10
10
  end
@@ -56,29 +56,47 @@ module Yell #:nodoc:
56
56
  :local7 => ::Syslog::LOG_LOCAL7
57
57
  }
58
58
 
59
- def initialize( options = {}, &block )
60
- ident options[:ident] || $0
61
- options options[:options] || [:pid, :cons]
62
- facility options[:facility]
63
-
64
- super( options, &block )
59
+ setup do |options|
60
+ self.ident = options[:ident] || $0
61
+ self.options = options[:options] || [:pid, :cons]
62
+ self.facility = options[:facility]
65
63
  end
66
64
 
67
- def stream
68
- @stream ||= _new_stream
65
+ write do |event|
66
+ stream.log( SeverityMap[event.level], clean(event.message) )
69
67
  end
70
68
 
71
- def close
72
- @stream.close if @stream.respond_to? :close
73
- rescue
74
- # do nothing
75
- ensure
76
- @stream = nil
69
+ close do
70
+ begin
71
+ @stream.close if @stream.respond_to? :close
72
+ rescue Exception
73
+ # do nothing
74
+ ensure
75
+ @stream = nil
76
+ end
77
77
  end
78
78
 
79
- # Identify the calling program
79
+
80
+ # Access the Syslog ident
81
+ attr_accessor :ident
82
+
83
+ # Access the Syslog options
84
+ attr_reader :options
85
+
86
+ # Access the Syslog facility
87
+ attr_reader :facility
88
+
89
+
90
+ # Deprecated: use :ident= in future
80
91
  def ident( val = nil )
81
- @ident = val
92
+ if val.nil?
93
+ @ident
94
+ else
95
+ # deprecate, but should still work
96
+ Yell._deprecate( "0.6.0", "Use :ident= for setting the Syslog ident" )
97
+
98
+ self.ident = val
99
+ end
82
100
  end
83
101
 
84
102
  # Set the log facility for Syslog
@@ -86,48 +104,69 @@ module Yell #:nodoc:
86
104
  # See {Yell::Adapters::Syslog::OptionMap OptionMap} for allowed values.
87
105
  #
88
106
  # @example Direct or Symbol
89
- # facility( Syslog::LOG_NDELAY )
90
- # facility( :ndelay )
107
+ # options = Syslog::LOG_CONS
108
+ # options = :cons
91
109
  #
92
110
  # @example Multiple
93
- # facility( :ndelay, Syslog::LOG_NDELAY ):
94
- def options( *values )
95
- @syslog_options = values.flatten.map do |v|
111
+ # options = [:ndelay, Syslog::LOG_NDELAY]
112
+ def options=( *values )
113
+ @options = values.flatten.map do |v|
96
114
  v.is_a?(Symbol) ? OptionMap[v] : v
97
115
  end.inject { |a, b| a | b }
98
116
  end
99
117
 
118
+ # Deprecated: use options= in future
119
+ def options( *values )
120
+ if values.empty?
121
+ @options
122
+ else
123
+ # deprecate, but should still work
124
+ Yell._deprecate( "0.6.0", "Use :options= for setting the Syslog options" )
125
+
126
+ self.options = values
127
+ end
128
+ end
129
+
130
+
100
131
  # Set the log facility for Syslog
101
132
  #
102
133
  # See {Yell::Adapters::Syslog::FacilityMap FacilityMap} for allowed values.
134
+ #
103
135
  # @example Direct or Symbol
104
- # facility( :user )
105
- # facility( Syslog::LOG_CONSOLE )
136
+ # facility = :user
137
+ # facility = Syslog::LOG_CONSOLE
106
138
  #
107
139
  # @example Multiple
108
- # facility( :user, Syslog::LOG_CONSOLE )
109
- def facility( *values )
140
+ # facility = [:user, Syslog::LOG_CONSOLE]
141
+ def facility=( *values )
110
142
  @facility = values.flatten.map do |v|
111
143
  v.is_a?(Symbol) ? FacilityMap[v] : v
112
144
  end.inject { |a, b| a | b }
113
145
  end
114
146
 
147
+ # Deprecated, use facility= in future
148
+ def facility( *values )
149
+ if values.empty?
150
+ @facility
151
+ else
152
+ # deprecate, but should still work
153
+ Yell._deprecate( "0.6.0", "Use :facility= for setting the Syslog facility" )
154
+
155
+ self.facility = values
156
+ end
157
+ end
115
158
 
116
- private
117
159
 
118
- def write!( event )
119
- stream.log( SeverityMap[event.level], clean(event.message) )
120
- rescue Exception => e
121
- close
160
+ private
122
161
 
123
- # re-raise the exception
124
- raise( e )
162
+ def stream
163
+ @stream ||= _new_stream
125
164
  end
126
165
 
127
166
  def _new_stream
128
167
  return ::Syslog if ::Syslog.opened?
129
168
 
130
- ::Syslog.open( @ident, @syslog_options, @facility )
169
+ ::Syslog.open( @ident, @options, @facility )
131
170
  end
132
171
 
133
172
  # Borrowed from [SyslogLogger](https://github.com/seattlerb/sysloglogger)
@@ -21,13 +21,10 @@
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
24
26
 
25
27
  require 'syslog'
26
-
27
28
  require 'yell'
28
29
 
29
30
  require File.dirname(__FILE__) + '/yell/adapters/syslog'
30
-
31
- module Yell #:nodoc:
32
- end
33
-
@@ -25,9 +25,9 @@ describe Yell::Adapters::Syslog do
25
25
  context "a new Yell::Adapters::Syslog instance" do
26
26
  subject { Yell::Adapters::Syslog.new }
27
27
 
28
- it { subject.instance_variable_get(:@ident).should == $0 }
29
- it { subject.instance_variable_get(:@syslog_options).should == (Syslog::LOG_PID | Syslog::LOG_CONS) }
30
- it { subject.instance_variable_get(:@facility).should be_nil }
28
+ it { subject.ident.should == $0 }
29
+ it { subject.options.should == (Syslog::LOG_PID | Syslog::LOG_CONS) }
30
+ it { subject.facility.should be_nil }
31
31
  end
32
32
 
33
33
  context "OptionMap" do
@@ -75,7 +75,7 @@ describe Yell::Adapters::Syslog do
75
75
  it "should be passed" do
76
76
  mock.proxy( Syslog ).open( "my ident", anything, anything )
77
77
 
78
- subject.ident "my ident"
78
+ subject.ident = "my ident"
79
79
  subject.write Yell::Event.new("INFO", "Hello World")
80
80
  end
81
81
  end
@@ -86,14 +86,14 @@ describe Yell::Adapters::Syslog do
86
86
  it "should be passed" do
87
87
  mock.proxy( Syslog ).open( anything, Syslog::LOG_NDELAY, anything )
88
88
 
89
- subject.options :ndelay
89
+ subject.options = :ndelay
90
90
  subject.write Yell::Event.new("INFO", "Hello World")
91
91
  end
92
92
 
93
93
  it "should work with multiple params" do
94
94
  mock.proxy( Syslog ).open( anything, Syslog::LOG_PID|Syslog::LOG_NDELAY, anything )
95
95
 
96
- subject.options :pid, :ndelay
96
+ subject.options = [:pid, :ndelay]
97
97
  subject.write Yell::Event.new("INFO", "Hello World")
98
98
  end
99
99
  end
@@ -104,14 +104,14 @@ describe Yell::Adapters::Syslog do
104
104
  it "should be passed" do
105
105
  mock.proxy( Syslog ).open( anything, anything, Syslog::LOG_USER )
106
106
 
107
- subject.facility :user
107
+ subject.facility = :user
108
108
  subject.write Yell::Event.new("INFO", "Hello World")
109
109
  end
110
110
 
111
111
  it "should work with multiple params" do
112
112
  mock.proxy( Syslog ).open( anything, anything, Syslog::LOG_DAEMON|Syslog::LOG_USER )
113
113
 
114
- subject.facility :daemon, :user
114
+ subject.facility = [:daemon, :user]
115
115
  subject.write Yell::Event.new("INFO", "Hello World")
116
116
  end
117
117
  end
@@ -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.4"
21
+ s.add_runtime_dependency "yell", "~> 0.6"
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.4.1
4
+ version: 0.6.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-01 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yell
16
- requirement: &70313191826040 !ruby/object:Gem::Requirement
16
+ requirement: &6751140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.4'
21
+ version: '0.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70313191826040
24
+ version_requirements: *6751140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70313191825640 !ruby/object:Gem::Requirement
27
+ requirement: &6750600 !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: *70313191825640
35
+ version_requirements: *6750600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rr
38
- requirement: &70313191825180 !ruby/object:Gem::Requirement
38
+ requirement: &7067360 !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: *70313191825180
46
+ version_requirements: *7067360
47
47
  description: Syslog adapter for Yell
48
48
  email:
49
49
  executables: []
@@ -82,11 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project: yell
85
- rubygems_version: 1.8.17
85
+ rubygems_version: 1.8.10
86
86
  signing_key:
87
87
  specification_version: 3
88
88
  summary: Yell - Your Extensible Logging Library
89
- test_files:
90
- - spec/spec_helper.rb
91
- - spec/yell/adapters/syslog_spec.rb
92
- has_rdoc:
89
+ test_files: []