@@ -32,13 +32,6 @@ def in_container_env(example)
32
32
33
33
subject { described_class . create_logger ( log_file ) }
34
34
35
- let ( :container_log ) { subject . try ( :wrapped_logger ) }
36
-
37
- before do
38
- # Hide the container logger output to STDOUT
39
- allow ( container_log . logdev ) . to receive ( :write ) if container_log
40
- end
41
-
42
35
it "responds to #<<" do
43
36
expect ( subject ) . to respond_to ( :<< )
44
37
end
@@ -64,11 +57,7 @@ def in_container_env(example)
64
57
end
65
58
66
59
it "#logdev" do
67
- if container_log
68
- expect ( subject . logdev ) . to be_nil
69
- else
70
- expect ( subject . logdev ) . to be_a Logger ::LogDevice
71
- end
60
+ expect ( subject . logdev ) . to be_a Logger ::LogDevice
72
61
end
73
62
74
63
describe "#datetime_format" do
@@ -90,20 +79,8 @@ def in_container_env(example)
90
79
subject . level = old_level
91
80
end
92
81
93
- it "forwards to the other loggers" do
94
- expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original
95
- expect ( container_log ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original if container_log
96
-
97
- subject . info ( "test message" )
98
- end
99
-
100
82
it "only forwards the message if the severity is correct" do
101
- if container_log
102
- expect ( subject . logdev ) . to be_nil
103
- expect ( container_log . logdev ) . not_to receive ( :write ) . with ( "test message" )
104
- else
105
- expect ( subject . logdev ) . not_to receive ( :write ) . with ( "test message" )
106
- end
83
+ expect ( subject . logdev ) . not_to receive ( :write ) . with ( "test message" )
107
84
108
85
subject . debug ( "test message" )
109
86
end
@@ -128,8 +105,7 @@ def in_container_env(example)
128
105
129
106
context "#<<" do
130
107
it "forwards to the other loggers" do
131
- expect ( subject ) . to receive ( :<< ) . with ( "test message" ) . and_call_original
132
- expect ( container_log ) . to receive ( :<< ) . with ( "test message" ) . and_call_original if container_log
108
+ expect ( subject ) . to receive ( :<< ) . with ( "test message" ) #.and_call_original
133
109
134
110
subject << "test message"
135
111
end
@@ -139,12 +115,9 @@ def in_container_env(example)
139
115
let ( :log_file ) { StringIO . new }
140
116
141
117
it "logs correctly" do
142
- expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original
143
- expect ( container_log ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original if container_log
118
+ expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" )
144
119
145
120
subject . info ( "test message" )
146
-
147
- expect ( log_file . string ) . to include ( "test message" ) unless container_log
148
121
end
149
122
end
150
123
@@ -154,12 +127,9 @@ def in_container_env(example)
154
127
after { log_file . delete if log_file . exist? }
155
128
156
129
it "logs correctly" do
157
- expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original
158
- expect ( container_log ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original if container_log
130
+ expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" )
159
131
160
132
subject . info ( "test message" )
161
-
162
- expect ( log_file . read ) . to include ( "test message" ) unless container_log
163
133
end
164
134
end
165
135
@@ -169,31 +139,20 @@ def in_container_env(example)
169
139
after { File . delete ( log_file ) if File . exist? ( log_file ) }
170
140
171
141
it "logs correctly" do
172
- expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original
173
- expect ( container_log ) . to receive ( :add ) . with ( 1 , nil , "test message" ) . and_call_original if container_log
142
+ expect ( subject ) . to receive ( :add ) . with ( 1 , nil , "test message" )
174
143
175
144
subject . info ( "test message" )
176
-
177
- expect ( File . read ( log_file ) ) . to include ( "test message" ) unless container_log
178
145
end
179
146
end
180
147
end
181
148
182
149
context "in a non-container environment" do
183
- it "does not have a container logger" do
184
- expect ( container_log ) . to be_nil
185
- end
186
-
187
150
include_examples "has basic logging functionality"
188
151
end
189
152
190
153
context "in a container environment" do
191
154
around { |example | in_container_env ( example ) }
192
155
193
- it "has a container logger" do
194
- expect ( container_log ) . to_not be_nil
195
- end
196
-
197
156
include_examples "has basic logging functionality"
198
157
end
199
158
end
@@ -212,12 +171,10 @@ def in_container_env(example)
212
171
213
172
it "will honor the log level in the container logger" do
214
173
log = described_class . create_logger ( log_file_name )
215
- container_log = log . wrapped_logger
216
174
217
175
described_class . apply_config_value ( { :level_foo => :error } , log , :level_foo )
218
176
219
- expect ( log . level ) . to eq ( Logger ::ERROR )
220
- expect ( container_log . level ) . to eq ( Logger ::ERROR )
177
+ expect ( log . level ) . to eq ( Logger ::ERROR )
221
178
end
222
179
end
223
180
end
0 commit comments