syslogger 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,12 +1,15 @@
1
1
  = syslogger
2
2
 
3
- A drop-in replacement for the standard Logger Ruby library, that logs to the syslog instead of a log file.
4
- Contrary to the SyslogLogger library, you can specify the facility and the syslog options.
3
+ A drop-in replacement for the standard Logger Ruby library, that logs to the
4
+ syslog instead of a log file. Contrary to the SyslogLogger library, you can
5
+ specify the facility and the syslog options.
5
6
 
6
7
  == Installation
8
+
7
9
  $ gem install syslogger
8
10
 
9
11
  == Usage
12
+
10
13
  require 'syslogger'
11
14
 
12
15
  # Will send all messages to the local0 facility, adding the process id in the message
@@ -22,27 +25,26 @@ Contrary to the SyslogLogger library, you can specify the facility and the syslo
22
25
  Documentation available at <http://rdoc.info/github/crohr/syslogger/master/file/README.rdoc>.
23
26
 
24
27
  == Development
25
- * Install +bundler+:
26
-
27
- $ gem install bundler
28
28
 
29
29
  * Install development dependencies:
30
30
 
31
- $ bundle install
31
+ $ gem install rake rdoc rspec
32
32
 
33
33
  * Run tests:
34
34
 
35
- $ bundle exec rake
35
+ $ rake spec
36
36
 
37
37
  * Package (do not forget to increment <tt>Syslogger:VERSION</tt>):
38
38
 
39
39
  $ gem build syslogger.gemspec
40
40
 
41
41
  == Contributions
42
+
42
43
  * crhym3
43
44
  * theflow
44
45
  * smulube
45
46
  * levent
47
+ * Flameeyes
46
48
 
47
49
  == Copyright
48
50
 
data/Rakefile CHANGED
@@ -1,16 +1,12 @@
1
- require 'spec/rake/spectask'
2
- require 'rake/rdoctask'
1
+ require 'rspec/core/rake_task'
2
+ require 'rdoc/task'
3
3
 
4
4
  $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
5
5
 
6
- Spec::Rake::SpecTask.new(:spec) do |spec|
7
- spec.libs << 'lib' << 'spec'
8
- spec.spec_files = FileList['spec/**/*_spec.rb']
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
7
  end
10
8
 
11
- Spec::Rake::SpecTask.new(:rcov) do |spec|
12
- spec.libs << 'lib' << 'spec'
13
- spec.pattern = 'spec/**/*_spec.rb'
9
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
14
10
  spec.rcov = true
15
11
  end
16
12
 
data/lib/syslogger.rb CHANGED
@@ -3,7 +3,7 @@ require 'logger'
3
3
 
4
4
  class Syslogger
5
5
 
6
- VERSION = "1.2.5"
6
+ VERSION = "1.2.6"
7
7
 
8
8
  attr_reader :level, :ident, :options, :facility
9
9
 
@@ -86,6 +86,12 @@ class Syslogger
86
86
  # Sets the minimum level for messages to be written in the log.
87
87
  # +level+:: one of <tt>Logger::DEBUG</tt>, <tt>Logger::INFO</tt>, <tt>Logger::WARN</tt>, <tt>Logger::ERROR</tt>, <tt>Logger::FATAL</tt>, <tt>Logger::UNKNOWN</tt>
88
88
  def level=(level)
89
+ level = Logger.const_get(level.to_s.upcase) if level.is_a?(Symbol)
90
+
91
+ unless level.is_a?(Fixnum)
92
+ raise ArgumentError.new("Invalid logger level `#{level.inspect}`")
93
+ end
94
+
89
95
  @level = level
90
96
  end
91
97
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'spec'
1
+ require 'rspec'
2
2
 
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -107,6 +107,47 @@ describe "Syslogger" do
107
107
  end
108
108
  end # describe "add"
109
109
 
110
+ describe "level=" do
111
+ before(:each) do
112
+ @logger = Syslogger.new("my_app", Syslog::LOG_PID, Syslog::LOG_USER)
113
+ end
114
+
115
+ { :debug => Logger::DEBUG,
116
+ :info => Logger::INFO,
117
+ :warn => Logger::WARN,
118
+ :error => Logger::ERROR,
119
+ :fatal => Logger::FATAL
120
+ }.each_pair do |level_symbol, level_value|
121
+ it "should allow using :#{level_symbol}" do
122
+ @logger.level = level_symbol
123
+ @logger.level.should equal level_value
124
+ end
125
+
126
+ it "should allow using Fixnum #{level_value}" do
127
+ @logger.level = level_value
128
+ @logger.level.should equal level_value
129
+ end
130
+ end
131
+
132
+ it "should not allow using random symbols" do
133
+ lambda {
134
+ @logger.level = :foo
135
+ }.should raise_error
136
+ end
137
+
138
+ it "should not allow using symbols mapping back to non-level constants" do
139
+ lambda {
140
+ @logger.level = :version
141
+ }.should raise_error
142
+ end
143
+
144
+ it "should not allow using strings" do
145
+ lambda {
146
+ @logger.level = "warn"
147
+ }.should raise_error
148
+ end
149
+ end # describe "level="
150
+
110
151
  describe ":level? methods" do
111
152
  before(:each) do
112
153
  @logger = Syslogger.new("my_app", Syslog::LOG_PID, Syslog::LOG_USER)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syslogger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 5
10
- version: 1.2.5
9
+ - 6
10
+ version: 1.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cyril Rohr
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-27 00:00:00 +02:00
18
+ date: 2012-02-27 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,11 +26,11 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 27
29
+ hash: 25
30
30
  segments:
31
31
  - 0
32
- - 8
33
- version: "0.8"
32
+ - 9
33
+ version: "0.9"
34
34
  type: :development
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -41,13 +41,29 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 9
44
+ hash: 3
45
45
  segments:
46
- - 1
47
- - 3
48
- version: "1.3"
46
+ - 2
47
+ - 0
48
+ version: "2.0"
49
49
  type: :development
50
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rdoc
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 27
60
+ segments:
61
+ - 2
62
+ - 4
63
+ - 2
64
+ version: 2.4.2
65
+ type: :development
66
+ version_requirements: *id003
51
67
  description: Same as SyslogLogger, but without the ridiculous number of dependencies and with the possibility to specify the syslog facility
52
68
  email:
53
69
  - cyril.rohr@gmail.com
@@ -96,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
112
  requirements: []
97
113
 
98
114
  rubyforge_project:
99
- rubygems_version: 1.5.2
115
+ rubygems_version: 1.6.2
100
116
  signing_key:
101
117
  specification_version: 3
102
118
  summary: Dead simple Ruby Syslog logger