rubysl-syslog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../shared/log', __FILE__)
2
+ require 'syslog'
3
+
4
+ describe "Syslog.notice" do
5
+ it_behaves_like :syslog_log, :notice
6
+ end
data/spec/open_spec.rb ADDED
@@ -0,0 +1,83 @@
1
+ require File.expand_path('../shared/reopen', __FILE__)
2
+ require 'syslog'
3
+
4
+ describe "Syslog.open" do
5
+ platform_is_not :windows do
6
+
7
+ before :each do
8
+ Syslog.opened?.should be_false
9
+ end
10
+
11
+ after :each do
12
+ Syslog.opened?.should be_false
13
+ end
14
+
15
+ it "returns the module" do
16
+ Syslog.open.should == Syslog
17
+ Syslog.close
18
+ Syslog.open("Test", 5, 9).should == Syslog
19
+ Syslog.close
20
+ end
21
+
22
+ it "receives an identity as first argument" do
23
+ Syslog.open("rubyspec")
24
+ Syslog.ident.should == "rubyspec"
25
+ Syslog.close
26
+ end
27
+
28
+ it "defaults the identity to $0" do
29
+ Syslog.open
30
+ Syslog.ident.should == $0
31
+ Syslog.close
32
+ end
33
+
34
+ it "receives the logging options as second argument" do
35
+ Syslog.open("rubyspec", Syslog::LOG_PID)
36
+ Syslog.options.should == Syslog::LOG_PID
37
+ Syslog.close
38
+ end
39
+
40
+ it "defaults the logging options to LOG_PID | LOG_CONS" do
41
+ Syslog.open
42
+ Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS
43
+ Syslog.close
44
+ end
45
+
46
+ it "receives a facility as third argument" do
47
+ Syslog.open("rubyspec", Syslog::LOG_PID, 0)
48
+ Syslog.facility.should == 0
49
+ Syslog.close
50
+ end
51
+
52
+ it "defaults the facility to LOG_USER" do
53
+ Syslog.open
54
+ Syslog.facility.should == Syslog::LOG_USER
55
+ Syslog.close
56
+ end
57
+
58
+ it "receives a block and calls it with the module" do
59
+ Syslog.open("rubyspec", 3, 8) do |s|
60
+ s.should == Syslog
61
+ s.ident.should == "rubyspec"
62
+ s.options.should == 3
63
+ s.facility.should == Syslog::LOG_USER
64
+ end
65
+ end
66
+
67
+ it "closes the log if after it receives a block" do
68
+ Syslog.open{ }
69
+ Syslog.opened?.should be_false
70
+ end
71
+
72
+ it "raises an error if the log is opened" do
73
+ Syslog.open
74
+ lambda { Syslog.open}.should raise_error
75
+ lambda { Syslog.close; Syslog.open }.should_not raise_error
76
+ Syslog.close
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "Syslog.open!" do
82
+ it_behaves_like :syslog_reopen, :open!
83
+ end
@@ -0,0 +1,35 @@
1
+ require 'syslog'
2
+
3
+ describe "Syslog.opened?" do
4
+ platform_is_not :windows do
5
+
6
+ before :each do
7
+ Syslog.opened?.should be_false
8
+ end
9
+
10
+ after :each do
11
+ Syslog.opened?.should be_false
12
+ end
13
+
14
+ it "returns true if the log is opened" do
15
+ Syslog.open
16
+ Syslog.opened?.should be_true
17
+ Syslog.close
18
+ end
19
+
20
+ it "returns false otherwise" do
21
+ Syslog.opened?.should be_false
22
+ Syslog.open
23
+ Syslog.close
24
+ Syslog.opened?.should be_false
25
+ end
26
+
27
+ it "works inside a block" do
28
+ Syslog.open do |s|
29
+ s.opened?.should be_true
30
+ Syslog.opened?.should be_true
31
+ end
32
+ Syslog.opened?.should be_false
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,44 @@
1
+ require 'syslog'
2
+
3
+ describe "Syslog.options" do
4
+ platform_is_not :windows do
5
+
6
+ before :each do
7
+ Syslog.opened?.should be_false
8
+ end
9
+
10
+ after :each do
11
+ Syslog.opened?.should be_false
12
+ end
13
+
14
+ it "returns the logging options" do
15
+ Syslog.open("rubyspec", Syslog::LOG_PID)
16
+ Syslog.options.should == Syslog::LOG_PID
17
+ Syslog.close
18
+ end
19
+
20
+ it "returns nil when the log is closed" do
21
+ Syslog.opened?.should be_false
22
+ Syslog.options.should == nil
23
+ end
24
+
25
+ it "defaults to LOG_PID | LOG_CONS" do
26
+ Syslog.open
27
+ Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS
28
+ Syslog.close
29
+ end
30
+
31
+ it "resets after each open call" do
32
+ Syslog.open
33
+ Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS
34
+
35
+ Syslog.open!("rubyspec", Syslog::LOG_PID)
36
+ Syslog.options.should == Syslog::LOG_PID
37
+ Syslog.close
38
+
39
+ Syslog.open
40
+ Syslog.options.should == Syslog::LOG_PID | Syslog::LOG_CONS
41
+ Syslog.close
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../shared/reopen', __FILE__)
2
+ require 'syslog'
3
+
4
+ describe "Syslog.reopen" do
5
+ it_behaves_like :syslog_reopen, :reopen
6
+ end
@@ -0,0 +1,41 @@
1
+ describe :syslog_log, :shared => true do
2
+ platform_is_not [:windows, :darwin] do
3
+ before :each do
4
+ Syslog.opened?.should be_false
5
+ end
6
+
7
+ after :each do
8
+ Syslog.opened?.should be_false
9
+ end
10
+
11
+ it "logs a message" do
12
+ lambda {
13
+ Syslog.open("rubyspec", Syslog::LOG_PERROR) do
14
+ Syslog.send(@method, "Hello")
15
+ end
16
+ }.should output_to_fd("rubyspec: Hello\n", $stderr)
17
+ end
18
+
19
+ it "accepts sprintf arguments" do
20
+ lambda {
21
+ Syslog.open("rubyspec", Syslog::LOG_PERROR) do
22
+ Syslog.send(@method, "Hello %s", "world")
23
+ Syslog.send(@method, "%d dogs", 2)
24
+ end
25
+ }.should output_to_fd("rubyspec: Hello world\nrubyspec: 2 dogs\n", $stderr)
26
+ end
27
+
28
+ it "works as an alias for Syslog.log" do
29
+ level = Syslog.const_get "LOG_#{@method.to_s.upcase}"
30
+ response = "rubyspec: Hello\n"
31
+ lambda {
32
+ Syslog.open("rubyspec", Syslog::LOG_PERROR) do
33
+ Syslog.send(@method, "Hello")
34
+ Syslog.log(level, "Hello")
35
+ end
36
+ # make sure the same thing is written to $stderr.
37
+ }.should output_to_fd(response * 2, $stderr)
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,40 @@
1
+ describe :syslog_reopen, :shared => true do
2
+ platform_is_not :windows do
3
+ before :each do
4
+ Syslog.opened?.should be_false
5
+ end
6
+
7
+ after :each do
8
+ Syslog.opened?.should be_false
9
+ end
10
+
11
+ it "reopens the log" do
12
+ Syslog.open
13
+ lambda { Syslog.send(@method)}.should_not raise_error
14
+ Syslog.opened?.should be_true
15
+ Syslog.close
16
+ end
17
+
18
+ it "fails with RuntimeError if the log is closed" do
19
+ lambda { Syslog.send(@method)}.should raise_error(RuntimeError)
20
+ end
21
+
22
+ it "receives the same parameters as Syslog.open" do
23
+ Syslog.open
24
+ Syslog.send(@method, "rubyspec", 3, 8) do |s|
25
+ s.should == Syslog
26
+ s.ident.should == "rubyspec"
27
+ s.options.should == 3
28
+ s.facility.should == Syslog::LOG_USER
29
+ s.opened?.should be_true
30
+ end
31
+ Syslog.opened?.should be_false
32
+ end
33
+
34
+ it "returns the module" do
35
+ Syslog.open
36
+ Syslog.send(@method).should == Syslog
37
+ Syslog.close
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../shared/log', __FILE__)
2
+ require 'syslog'
3
+
4
+ describe "Syslog.warning" do
5
+ it_behaves_like :syslog_log, :warning
6
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubysl-syslog
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Shirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi2-generators
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubysl-prettyprint
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ description: Ruby standard library syslog.
84
+ email:
85
+ - brixen@gmail.com
86
+ executables: []
87
+ extensions:
88
+ - lib/rubysl/syslog/extconf.rb
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - lib/rubysl/syslog.rb
98
+ - lib/rubysl/syslog/extconf.rb
99
+ - lib/rubysl/syslog/syslog.rb.ffi
100
+ - lib/rubysl/syslog/version.rb
101
+ - lib/syslog.rb
102
+ - rubysl-syslog.gemspec
103
+ - spec/alert_spec.rb
104
+ - spec/close_spec.rb
105
+ - spec/constants_spec.rb
106
+ - spec/crit_spec.rb
107
+ - spec/debug_spec.rb
108
+ - spec/emerg_spec.rb
109
+ - spec/err_spec.rb
110
+ - spec/facility_spec.rb
111
+ - spec/ident_spec.rb
112
+ - spec/info_spec.rb
113
+ - spec/inspect_spec.rb
114
+ - spec/instance_spec.rb
115
+ - spec/log_spec.rb
116
+ - spec/mask_spec.rb
117
+ - spec/notice_spec.rb
118
+ - spec/open_spec.rb
119
+ - spec/opened_spec.rb
120
+ - spec/options_spec.rb
121
+ - spec/reopen_spec.rb
122
+ - spec/shared/log.rb
123
+ - spec/shared/reopen.rb
124
+ - spec/warning_spec.rb
125
+ homepage: https://github.com/rubysl/rubysl-syslog
126
+ licenses:
127
+ - BSD
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ version: 1.8.7
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.0.7
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Ruby standard library syslog.
149
+ test_files:
150
+ - spec/alert_spec.rb
151
+ - spec/close_spec.rb
152
+ - spec/constants_spec.rb
153
+ - spec/crit_spec.rb
154
+ - spec/debug_spec.rb
155
+ - spec/emerg_spec.rb
156
+ - spec/err_spec.rb
157
+ - spec/facility_spec.rb
158
+ - spec/ident_spec.rb
159
+ - spec/info_spec.rb
160
+ - spec/inspect_spec.rb
161
+ - spec/instance_spec.rb
162
+ - spec/log_spec.rb
163
+ - spec/mask_spec.rb
164
+ - spec/notice_spec.rb
165
+ - spec/open_spec.rb
166
+ - spec/opened_spec.rb
167
+ - spec/options_spec.rb
168
+ - spec/reopen_spec.rb
169
+ - spec/shared/log.rb
170
+ - spec/shared/reopen.rb
171
+ - spec/warning_spec.rb