yell 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -1
- data/.travis.yml +1 -2
- data/Gemfile +5 -1
- data/README.md +67 -14
- data/examples/004.1-colorizing-the-log-output.rb +4 -4
- data/lib/yell.rb +19 -10
- data/lib/yell/adapters.rb +23 -26
- data/lib/yell/adapters/base.rb +8 -2
- data/lib/yell/adapters/datefile.rb +45 -42
- data/lib/yell/adapters/file.rb +10 -5
- data/lib/yell/adapters/io.rb +52 -48
- data/lib/yell/adapters/streams.rb +10 -2
- data/lib/yell/configuration.rb +1 -1
- data/lib/yell/event.rb +4 -4
- data/lib/yell/formatter.rb +11 -25
- data/lib/yell/helpers/adapters.rb +51 -0
- data/lib/yell/helpers/base.rb +19 -0
- data/lib/yell/helpers/formatter.rb +31 -0
- data/lib/yell/helpers/level.rb +36 -0
- data/lib/yell/helpers/silencer.rb +32 -0
- data/lib/yell/helpers/tracer.rb +48 -0
- data/lib/yell/level.rb +38 -47
- data/lib/yell/logger.rb +53 -73
- data/lib/yell/repository.rb +31 -29
- data/lib/yell/silencer.rb +69 -0
- data/lib/yell/version.rb +1 -1
- data/spec/spec_helper.rb +21 -9
- data/spec/yell/adapters/base_spec.rb +17 -34
- data/spec/yell/adapters/datefile_spec.rb +109 -66
- data/spec/yell/adapters/file_spec.rb +18 -18
- data/spec/yell/adapters/io_spec.rb +17 -13
- data/spec/yell/adapters/streams_spec.rb +7 -7
- data/spec/yell/adapters_spec.rb +18 -23
- data/spec/yell/configuration_spec.rb +7 -7
- data/spec/yell/event_spec.rb +25 -27
- data/spec/yell/formatter_spec.rb +89 -82
- data/spec/yell/level_spec.rb +119 -94
- data/spec/yell/loggable_spec.rb +6 -5
- data/spec/yell/logger_spec.rb +106 -66
- data/spec/yell/repository_spec.rb +23 -38
- data/spec/yell/silencer_spec.rb +49 -0
- data/spec/yell_spec.rb +24 -27
- metadata +16 -9
data/spec/yell/level_spec.rb
CHANGED
@@ -5,127 +5,139 @@ describe Yell::Level do
|
|
5
5
|
context "default" do
|
6
6
|
let(:level) { Yell::Level.new }
|
7
7
|
|
8
|
-
it
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
it "should should return correctly" do
|
9
|
+
expect(level.at?(:debug)).to be_true
|
10
|
+
expect(level.at?(:info)).to be_true
|
11
|
+
expect(level.at?(:warn)).to be_true
|
12
|
+
expect(level.at?(:error)).to be_true
|
13
|
+
expect(level.at?(:fatal)).to be_true
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
context "given a Symbol" do
|
16
|
-
let(:level) { Yell::Level.new(
|
18
|
+
let(:level) { Yell::Level.new(severity) }
|
17
19
|
|
18
|
-
context :debug do
|
19
|
-
|
20
|
+
context ":debug" do
|
21
|
+
let(:severity) { :debug }
|
20
22
|
|
21
|
-
it
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
it "should should return correctly" do
|
24
|
+
expect(level.at?(:debug)).to be_true
|
25
|
+
expect(level.at?(:info)).to be_true
|
26
|
+
expect(level.at?(:warn)).to be_true
|
27
|
+
expect(level.at?(:error)).to be_true
|
28
|
+
expect(level.at?(:fatal)).to be_true
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
|
-
context :info do
|
29
|
-
|
32
|
+
context ":info" do
|
33
|
+
let(:severity) { :info }
|
30
34
|
|
31
|
-
it
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
it "should should return correctly" do
|
36
|
+
expect(level.at?(:debug)).to be_false
|
37
|
+
expect(level.at?(:info)).to be_true
|
38
|
+
expect(level.at?(:warn)).to be_true
|
39
|
+
expect(level.at?(:error)).to be_true
|
40
|
+
expect(level.at?(:fatal)).to be_true
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
|
-
context :warn do
|
39
|
-
|
44
|
+
context ":warn" do
|
45
|
+
let(:severity) { :warn }
|
40
46
|
|
41
|
-
it
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
it "should should return correctly" do
|
48
|
+
expect(level.at?(:debug)).to be_false
|
49
|
+
expect(level.at?(:info)).to be_false
|
50
|
+
expect(level.at?(:warn)).to be_true
|
51
|
+
expect(level.at?(:error)).to be_true
|
52
|
+
expect(level.at?(:fatal)).to be_true
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
|
-
context :error do
|
49
|
-
|
56
|
+
context ":error" do
|
57
|
+
let(:severity) { :error }
|
50
58
|
|
51
|
-
it
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
it "should should return correctly" do
|
60
|
+
expect(level.at?(:debug)).to be_false
|
61
|
+
expect(level.at?(:info)).to be_false
|
62
|
+
expect(level.at?(:warn)).to be_false
|
63
|
+
expect(level.at?(:error)).to be_true
|
64
|
+
expect(level.at?(:fatal)).to be_true
|
65
|
+
end
|
56
66
|
end
|
57
67
|
|
58
|
-
context :fatal do
|
59
|
-
|
68
|
+
context ":fatal" do
|
69
|
+
let(:severity) { :fatal }
|
60
70
|
|
61
|
-
it
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
it "should should return correctly" do
|
72
|
+
expect(level.at?(:debug)).to be_false
|
73
|
+
expect(level.at?(:info)).to be_false
|
74
|
+
expect(level.at?(:warn)).to be_false
|
75
|
+
expect(level.at?(:error)).to be_false
|
76
|
+
expect(level.at?(:fatal)).to be_true
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
69
81
|
context "given a String" do
|
70
|
-
let(:level) { Yell::Level.new(
|
82
|
+
let(:level) { Yell::Level.new(severity) }
|
71
83
|
|
72
84
|
context "basic string" do
|
73
|
-
|
74
|
-
|
75
|
-
it "should
|
76
|
-
level.at?(:debug).
|
77
|
-
level.at?(:info).
|
78
|
-
level.at?(:warn).
|
79
|
-
level.at?(:error).
|
80
|
-
level.at?(:fatal).
|
85
|
+
let(:severity) { 'error' }
|
86
|
+
|
87
|
+
it "should should return correctly" do
|
88
|
+
expect(level.at?(:debug)).to be_false
|
89
|
+
expect(level.at?(:info)).to be_false
|
90
|
+
expect(level.at?(:warn)).to be_false
|
91
|
+
expect(level.at?(:error)).to be_true
|
92
|
+
expect(level.at?(:fatal)).to be_true
|
81
93
|
end
|
82
94
|
end
|
83
95
|
|
84
96
|
context "complex string with outer boundaries" do
|
85
|
-
|
86
|
-
|
87
|
-
it "should
|
88
|
-
level.at?(:debug).
|
89
|
-
level.at?(:info).
|
90
|
-
level.at?(:warn).
|
91
|
-
level.at?(:error).
|
92
|
-
level.at?(:fatal).
|
97
|
+
let(:severity) { 'gte.info lte.error' }
|
98
|
+
|
99
|
+
it "should should return correctly" do
|
100
|
+
expect(level.at?(:debug)).to be_false
|
101
|
+
expect(level.at?(:info)).to be_true
|
102
|
+
expect(level.at?(:warn)).to be_true
|
103
|
+
expect(level.at?(:error)).to be_true
|
104
|
+
expect(level.at?(:fatal)).to be_false
|
93
105
|
end
|
94
106
|
end
|
95
107
|
|
96
108
|
context "complex string with inner boundaries" do
|
97
|
-
|
109
|
+
let(:severity) { 'gt.info lt.error' }
|
98
110
|
|
99
111
|
it "should be valid" do
|
100
|
-
level.at?(:debug).
|
101
|
-
level.at?(:info).
|
102
|
-
level.at?(:warn).
|
103
|
-
level.at?(:error).
|
104
|
-
level.at?(:fatal).
|
112
|
+
expect(level.at?(:debug)).to be_false
|
113
|
+
expect(level.at?(:info)).to be_false
|
114
|
+
expect(level.at?(:warn)).to be_true
|
115
|
+
expect(level.at?(:error)).to be_false
|
116
|
+
expect(level.at?(:fatal)).to be_false
|
105
117
|
end
|
106
118
|
end
|
107
119
|
|
108
120
|
context "complex string with precise boundaries" do
|
109
|
-
|
121
|
+
let(:severity) { 'at.info at.error' }
|
110
122
|
|
111
123
|
it "should be valid" do
|
112
|
-
level.at?(:debug).
|
113
|
-
level.at?(:info).
|
114
|
-
level.at?(:warn).
|
115
|
-
level.at?(:error).
|
116
|
-
level.at?(:fatal).
|
124
|
+
expect(level.at?(:debug)).to be_false
|
125
|
+
expect(level.at?(:info)).to be_true
|
126
|
+
expect(level.at?(:warn)).to be_false
|
127
|
+
expect(level.at?(:error)).to be_true
|
128
|
+
expect(level.at?(:fatal)).to be_false
|
117
129
|
end
|
118
130
|
end
|
119
131
|
|
120
132
|
context "complex string with combined boundaries" do
|
121
|
-
|
133
|
+
let(:severity) { 'gte.error at.debug' }
|
122
134
|
|
123
135
|
it "should be valid" do
|
124
|
-
level.at?(:debug).
|
125
|
-
level.at?(:info).
|
126
|
-
level.at?(:warn).
|
127
|
-
level.at?(:error).
|
128
|
-
level.at?(:fatal).
|
136
|
+
expect(level.at?(:debug)).to be_true
|
137
|
+
expect(level.at?(:info)).to be_false
|
138
|
+
expect(level.at?(:warn)).to be_false
|
139
|
+
expect(level.at?(:error)).to be_true
|
140
|
+
expect(level.at?(:fatal)).to be_true
|
129
141
|
end
|
130
142
|
end
|
131
143
|
end
|
@@ -133,43 +145,56 @@ describe Yell::Level do
|
|
133
145
|
context "given an Array" do
|
134
146
|
let(:level) { Yell::Level.new( [:debug, :warn, :fatal] ) }
|
135
147
|
|
136
|
-
it
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
148
|
+
it "should return correctly" do
|
149
|
+
expect(level.at?(:debug)).to be_true
|
150
|
+
expect(level.at?(:info)).to be_false
|
151
|
+
expect(level.at?(:warn)).to be_true
|
152
|
+
expect(level.at?(:error)).to be_false
|
153
|
+
expect(level.at?(:fatal)).to be_true
|
154
|
+
end
|
141
155
|
end
|
142
156
|
|
143
157
|
context "given a Range" do
|
144
158
|
let(:level) { Yell::Level.new( (1..3) ) }
|
145
159
|
|
146
|
-
it
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
it "should return correctly" do
|
161
|
+
expect(level.at?(:debug)).to be_false
|
162
|
+
expect(level.at?(:info)).to be_true
|
163
|
+
expect(level.at?(:warn)).to be_true
|
164
|
+
expect(level.at?(:error)).to be_true
|
165
|
+
expect(level.at?(:fatal)).to be_false
|
166
|
+
end
|
151
167
|
end
|
152
168
|
|
153
169
|
context "given a Yell::Level instance" do
|
154
170
|
let(:level) { Yell::Level.new(:warn) }
|
155
171
|
|
156
|
-
it
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
172
|
+
it "should return correctly" do
|
173
|
+
expect(level.at?(:debug)).to be_false
|
174
|
+
expect(level.at?(:info)).to be_false
|
175
|
+
expect(level.at?(:warn)).to be_true
|
176
|
+
expect(level.at?(:error)).to be_true
|
177
|
+
expect(level.at?(:fatal)).to be_true
|
178
|
+
end
|
161
179
|
end
|
162
180
|
|
163
181
|
context "backwards compatibility" do
|
164
182
|
let(:level) { Yell::Level.new :warn }
|
165
183
|
|
166
|
-
it
|
167
|
-
|
184
|
+
it "should return correctly to :to_i" do
|
185
|
+
expect(level.to_i).to eq(2)
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should typecast with Integer correctly" do
|
189
|
+
expect(Integer(level)).to eq(2)
|
190
|
+
end
|
168
191
|
|
169
192
|
it "should be compatible when passing to array (https://github.com/rudionrails/yell/issues/1)" do
|
170
193
|
severities = %w(FINE INFO WARNING SEVERE SEVERE INFO)
|
171
194
|
|
172
|
-
severities[level].
|
195
|
+
expect(severities[level]).to eq("WARNING")
|
173
196
|
end
|
174
197
|
end
|
198
|
+
|
175
199
|
end
|
200
|
+
|
data/spec/yell/loggable_spec.rb
CHANGED
@@ -5,14 +5,15 @@ class LoggableFactory
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe Yell::Loggable do
|
8
|
-
|
8
|
+
let(:factory) { LoggableFactory.new }
|
9
|
+
subject { factory }
|
9
10
|
|
10
|
-
it { should respond_to
|
11
|
+
it { should respond_to(:logger) }
|
11
12
|
|
12
|
-
it "
|
13
|
-
mock(
|
13
|
+
it "should make a lookup in the Yell::Repository" do
|
14
|
+
mock(Yell::Repository)[LoggableFactory]
|
14
15
|
|
15
|
-
|
16
|
+
factory.logger
|
16
17
|
end
|
17
18
|
|
18
19
|
end
|
data/spec/yell/logger_spec.rb
CHANGED
@@ -15,112 +15,129 @@ end
|
|
15
15
|
describe Yell::Logger do
|
16
16
|
let(:filename) { fixture_path + '/logger.log' }
|
17
17
|
|
18
|
-
|
18
|
+
describe "a Logger instance" do
|
19
19
|
let(:logger) { Yell::Logger.new }
|
20
|
+
subject { logger }
|
20
21
|
|
21
22
|
its(:name) { should be_nil }
|
22
23
|
|
23
24
|
context "log methods" do
|
24
|
-
|
25
|
+
it { should respond_to(:debug) }
|
26
|
+
it { should respond_to(:debug?) }
|
25
27
|
|
26
|
-
it { should respond_to
|
27
|
-
it { should respond_to
|
28
|
+
it { should respond_to(:info) }
|
29
|
+
it { should respond_to(:info?) }
|
28
30
|
|
29
|
-
it { should respond_to
|
30
|
-
it { should respond_to
|
31
|
+
it { should respond_to(:warn) }
|
32
|
+
it { should respond_to(:warn?) }
|
31
33
|
|
32
|
-
it { should respond_to
|
33
|
-
it { should respond_to
|
34
|
+
it { should respond_to(:error) }
|
35
|
+
it { should respond_to(:error?) }
|
34
36
|
|
35
|
-
it { should respond_to
|
36
|
-
it { should respond_to
|
37
|
+
it { should respond_to(:fatal) }
|
38
|
+
it { should respond_to(:fatal?) }
|
37
39
|
|
38
|
-
it { should respond_to
|
39
|
-
it { should respond_to
|
40
|
-
|
41
|
-
it { should respond_to :unknown }
|
42
|
-
it { should respond_to :unknown? }
|
40
|
+
it { should respond_to(:unknown) }
|
41
|
+
it { should respond_to(:unknown?) }
|
43
42
|
end
|
44
43
|
|
45
|
-
context "default
|
46
|
-
|
44
|
+
context "default #adapters" do
|
45
|
+
subject { logger.adapters }
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
its(:size) { should eq(1) }
|
48
|
+
its(:first) { should be_kind_of(Yell::Adapters::File) }
|
50
49
|
end
|
51
50
|
|
52
|
-
context "default
|
51
|
+
context "default #level" do
|
53
52
|
subject { logger.level }
|
54
53
|
|
55
54
|
it { should be_instance_of(Yell::Level) }
|
56
|
-
its(:severities) { should
|
55
|
+
its(:severities) { should eq([true, true, true, true, true, true]) }
|
57
56
|
end
|
58
57
|
|
59
|
-
context "default
|
58
|
+
context "default #trace" do
|
60
59
|
subject { logger.trace }
|
61
60
|
|
62
61
|
it { should be_instance_of(Yell::Level) }
|
63
|
-
its(:severities) { should
|
62
|
+
its(:severities) { should eq([false, false, false, true, true, true]) } # from error onwards
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
|
-
|
66
|
+
describe "initialize with #name" do
|
68
67
|
let(:name) { 'test' }
|
69
68
|
let!(:logger) { Yell.new(:name => name) }
|
70
69
|
|
71
|
-
it "should set the logger's name" do
|
72
|
-
logger.name.should == name
|
73
|
-
end
|
74
|
-
|
75
70
|
it "should be added to the repository" do
|
76
|
-
Yell::Repository[name].
|
71
|
+
expect(Yell::Repository[name]).to eq(logger)
|
77
72
|
end
|
78
73
|
end
|
79
74
|
|
80
|
-
context "initialize with
|
75
|
+
context "initialize with #level" do
|
76
|
+
let(:level) { :error }
|
77
|
+
let(:logger) { Yell.new(:level => level) }
|
78
|
+
subject { logger.level }
|
79
|
+
|
80
|
+
it { should be_instance_of(Yell::Level) }
|
81
|
+
its(:severities) { should eq([false, false, false, true, true, true]) }
|
82
|
+
end
|
83
|
+
|
84
|
+
context "initialize with #trace" do
|
85
|
+
let(:trace) { :info }
|
86
|
+
let(:logger) { Yell.new(:trace => trace) }
|
87
|
+
subject { logger.trace }
|
88
|
+
|
89
|
+
it { should be_instance_of(Yell::Level) }
|
90
|
+
its(:severities) { should eq([false, true, true, true, true, true]) }
|
91
|
+
end
|
92
|
+
|
93
|
+
context "initialize with #silence" do
|
94
|
+
let(:silence) { "test" }
|
95
|
+
let(:logger) { Yell.new(:silence => silence) }
|
96
|
+
subject { logger.silencer }
|
97
|
+
|
98
|
+
it { should be_instance_of(Yell::Silencer) }
|
99
|
+
its(:patterns) { should eq([silence]) }
|
81
100
|
end
|
82
101
|
|
83
|
-
context "initialize with a
|
102
|
+
context "initialize with a #filename" do
|
84
103
|
it "should call adapter with :file" do
|
85
|
-
mock.proxy(
|
104
|
+
mock.proxy(Yell::Adapters::File).new(:filename => filename)
|
86
105
|
|
87
|
-
Yell::Logger.new
|
106
|
+
Yell::Logger.new(filename)
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
91
|
-
context "initialize with a
|
110
|
+
context "initialize with a #filename of Pathname type" do
|
111
|
+
let(:pathname) { Pathname.new(filename) }
|
112
|
+
|
92
113
|
it "should call adapter with :file" do
|
93
|
-
mock.proxy(
|
114
|
+
mock.proxy(Yell::Adapters::File).new(:filename => pathname)
|
94
115
|
|
95
|
-
Yell::Logger.new
|
116
|
+
Yell::Logger.new(pathname)
|
96
117
|
end
|
97
118
|
end
|
98
119
|
|
99
120
|
context "initialize with a :stdout adapter" do
|
100
|
-
before
|
101
|
-
mock.proxy( Yell::Adapters::Stdout ).new( anything )
|
102
|
-
end
|
121
|
+
before { mock.proxy(Yell::Adapters::Stdout).new(anything) }
|
103
122
|
|
104
123
|
it "should call adapter with STDOUT" do
|
105
|
-
Yell::Logger.new
|
124
|
+
Yell::Logger.new(STDOUT)
|
106
125
|
end
|
107
126
|
|
108
127
|
it "should call adapter with :stdout" do
|
109
|
-
Yell::Logger.new
|
128
|
+
Yell::Logger.new(:stdout)
|
110
129
|
end
|
111
130
|
end
|
112
131
|
|
113
132
|
context "initialize with a :stderr adapter" do
|
114
|
-
before
|
115
|
-
mock.proxy( Yell::Adapters::Stderr ).new( anything )
|
116
|
-
end
|
133
|
+
before { mock.proxy(Yell::Adapters::Stderr).new(anything) }
|
117
134
|
|
118
135
|
it "should call adapter with STDERR" do
|
119
|
-
Yell::Logger.new
|
136
|
+
Yell::Logger.new(STDERR)
|
120
137
|
end
|
121
138
|
|
122
139
|
it "should call adapter with :stderr" do
|
123
|
-
Yell::Logger.new
|
140
|
+
Yell::Logger.new(:stderr)
|
124
141
|
end
|
125
142
|
end
|
126
143
|
|
@@ -134,8 +151,8 @@ describe Yell::Logger do
|
|
134
151
|
Yell::Logger.new(:level => level) { |l| l.adapter(:stdout) }
|
135
152
|
end
|
136
153
|
|
137
|
-
its(:level) { should
|
138
|
-
its('adapters.size') { should
|
154
|
+
its(:level) { should eq(level) }
|
155
|
+
its('adapters.size') { should eq(1) }
|
139
156
|
its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
|
140
157
|
end
|
141
158
|
|
@@ -144,32 +161,32 @@ describe Yell::Logger do
|
|
144
161
|
Yell::Logger.new(:level => level) { adapter(:stdout) }
|
145
162
|
end
|
146
163
|
|
147
|
-
its(:level) { should
|
148
|
-
its('adapters.size') { should
|
164
|
+
its(:level) { should eq(level) }
|
165
|
+
its('adapters.size') { should eq(1) }
|
149
166
|
its('adapters.first') { should be_instance_of(Yell::Adapters::Stdout) }
|
150
167
|
end
|
151
168
|
end
|
152
169
|
|
153
|
-
context "initialize with
|
170
|
+
context "initialize with #adapters option" do
|
154
171
|
let(:logger) do
|
155
|
-
Yell::Logger.new
|
172
|
+
Yell::Logger.new(:adapters => [:stdout, {:stderr => {:level => :error}}])
|
156
173
|
end
|
157
174
|
|
158
|
-
let(:adapters) { logger.instance_variable_get
|
175
|
+
let(:adapters) { logger.instance_variable_get(:@adapters) }
|
159
176
|
let(:stdout) { adapters.first }
|
160
177
|
let(:stderr) { adapters.last }
|
161
178
|
|
162
179
|
it "should define those adapters" do
|
163
|
-
adapters.size.
|
180
|
+
expect(adapters.size).to eq(2)
|
164
181
|
|
165
|
-
stdout.
|
166
|
-
stderr.
|
182
|
+
expect(stdout).to be_kind_of(Yell::Adapters::Stdout)
|
183
|
+
expect(stderr).to be_kind_of(Yell::Adapters::Stderr)
|
167
184
|
end
|
168
185
|
|
169
186
|
it "should pass :level to :stderr adapter" do
|
170
|
-
stderr.level.at?(:warn).
|
171
|
-
stderr.level.at?(:error).
|
172
|
-
stderr.level.at?(:fatal).
|
187
|
+
expect(stderr.level.at?(:warn)).to be_false
|
188
|
+
expect(stderr.level.at?(:error)).to be_true
|
189
|
+
expect(stderr.level.at?(:fatal)).to be_true
|
173
190
|
end
|
174
191
|
end
|
175
192
|
|
@@ -181,8 +198,8 @@ describe Yell::Logger do
|
|
181
198
|
factory = LoggerFactory.new
|
182
199
|
factory.logger = logger
|
183
200
|
|
184
|
-
mock(
|
185
|
-
mock(
|
201
|
+
mock(stdout.send(:stream)).syswrite("#{__FILE__}, 7: foo\n")
|
202
|
+
mock(stdout.send(:stream)).syswrite("#{__FILE__}, 11: bar\n")
|
186
203
|
|
187
204
|
factory.foo
|
188
205
|
factory.bar
|
@@ -195,27 +212,50 @@ describe Yell::Logger do
|
|
195
212
|
|
196
213
|
it "should output a single message" do
|
197
214
|
logger.info "Hello World"
|
198
|
-
|
215
|
+
|
216
|
+
expect(line).to eq("Hello World\n")
|
199
217
|
end
|
200
218
|
|
201
219
|
it "should output multiple messages" do
|
202
220
|
logger.info "Hello", "W", "o", "r", "l", "d"
|
203
|
-
|
221
|
+
|
222
|
+
expect(line).to eq("Hello W o r l d\n")
|
204
223
|
end
|
205
224
|
|
206
225
|
it "should output a hash and message" do
|
207
226
|
logger.info "Hello World", :test => :message
|
208
|
-
|
227
|
+
|
228
|
+
expect(line).to eq("Hello World test: message\n")
|
209
229
|
end
|
210
230
|
|
211
231
|
it "should output a hash and message" do
|
212
232
|
logger.info( {:test => :message}, "Hello World" )
|
213
|
-
|
233
|
+
|
234
|
+
expect(line).to eq("test: message Hello World\n")
|
214
235
|
end
|
215
236
|
|
216
237
|
it "should output a hash and block" do
|
217
238
|
logger.info(:test => :message) { "Hello World" }
|
218
|
-
|
239
|
+
|
240
|
+
expect(line).to eq("test: message Hello World\n")
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "logging with a silencer" do
|
245
|
+
let(:silence) { "this" }
|
246
|
+
let(:stdout) { Yell::Adapters::Stdout.new }
|
247
|
+
let(:logger) { Yell::Logger.new(stdout, :silence => silence) }
|
248
|
+
|
249
|
+
it "should not pass a matching message to any adapter" do
|
250
|
+
dont_allow(stdout).write
|
251
|
+
|
252
|
+
logger.info "this should not be logged"
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should pass a non-matching message to any adapter" do
|
256
|
+
mock(stdout).write(is_a(Yell::Event))
|
257
|
+
|
258
|
+
logger.info "that should be logged"
|
219
259
|
end
|
220
260
|
end
|
221
261
|
|