|
20 | 20 | require 'java_buildpack/logging/logger_factory' |
21 | 21 | require 'java_buildpack/util/configuration_utils' |
22 | 22 |
|
23 | | -describe JavaBuildpack::Logging::LoggerFactory do |
| 23 | +describe JavaBuildpack::Logging::LoggerFactory, :focus do |
24 | 24 | include_context 'console_helper' |
25 | 25 | include_context 'logging_helper' |
26 | 26 |
|
|
31 | 31 |
|
32 | 32 | trigger |
33 | 33 |
|
34 | | - expect(log_contents).to match /DEBUG debug-message/ |
35 | | - expect(log_contents).to match /INFO info-message/ |
36 | | - expect(log_contents).to match /WARN warn-message/ |
37 | | - expect(log_contents).to match /ERROR error-message/ |
38 | | - expect(log_contents).to match /FATAL fatal-message/ |
| 34 | + expect(log_contents).to match /DEBUG block-debug-message/ |
| 35 | + expect(log_contents).to match /INFO block-info-message/ |
| 36 | + expect(log_contents).to match /WARN block-warn-message/ |
| 37 | + expect(log_contents).to match /ERROR block-error-message/ |
| 38 | + expect(log_contents).to match /FATAL block-fatal-message/ |
| 39 | + |
| 40 | + expect(log_contents).to match /DEBUG param-debug-message/ |
| 41 | + expect(log_contents).to match /INFO param-info-message/ |
| 42 | + expect(log_contents).to match /WARN param-warn-message/ |
| 43 | + expect(log_contents).to match /ERROR param-error-message/ |
| 44 | + expect(log_contents).to match /FATAL param-fatal-message/ |
39 | 45 | end |
40 | 46 |
|
41 | 47 | it 'should log all levels to console when JBP_LOG_LEVEL set to DEBUG', |
42 | 48 | log_level: 'DEBUG' do |
43 | 49 |
|
44 | 50 | trigger |
45 | 51 |
|
46 | | - expect(stderr.string).to match /DEBUG debug-message/ |
47 | | - expect(stderr.string).to match /INFO info-message/ |
48 | | - expect(stderr.string).to match /WARN warn-message/ |
49 | | - expect(stderr.string).to match /ERROR error-message/ |
50 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 52 | + expect(stderr.string).to match /DEBUG block-debug-message/ |
| 53 | + expect(stderr.string).to match /INFO block-info-message/ |
| 54 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 55 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 56 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 57 | + |
| 58 | + expect(stderr.string).to match /DEBUG param-debug-message/ |
| 59 | + expect(stderr.string).to match /INFO param-info-message/ |
| 60 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 61 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 62 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
51 | 63 | end |
52 | 64 |
|
53 | 65 | it 'should log all levels above INFO to console when JBP_LOG_LEVEL set to INFO', |
54 | 66 | log_level: 'INFO' do |
55 | 67 |
|
56 | 68 | trigger |
57 | 69 |
|
58 | | - expect(stderr.string).not_to match /DEBUG debug-message/ |
59 | | - expect(stderr.string).to match /INFO info-message/ |
60 | | - expect(stderr.string).to match /WARN warn-message/ |
61 | | - expect(stderr.string).to match /ERROR error-message/ |
62 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 70 | + expect(stderr.string).not_to match /DEBUG block-debug-message/ |
| 71 | + expect(stderr.string).to match /INFO block-info-message/ |
| 72 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 73 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 74 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 75 | + |
| 76 | + expect(stderr.string).not_to match /DEBUG param-debug-message/ |
| 77 | + expect(stderr.string).to match /INFO param-info-message/ |
| 78 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 79 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 80 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
63 | 81 | end |
64 | 82 |
|
65 | 83 | it 'should log all levels above WARN to console when JBP_LOG_LEVEL set to WARN', |
66 | 84 | log_level: 'WARN' do |
67 | 85 |
|
68 | 86 | trigger |
69 | 87 |
|
70 | | - expect(stderr.string).not_to match /DEBUG debug-message/ |
71 | | - expect(stderr.string).not_to match /INFO info-message/ |
72 | | - expect(stderr.string).to match /WARN warn-message/ |
73 | | - expect(stderr.string).to match /ERROR error-message/ |
74 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 88 | + expect(stderr.string).not_to match /DEBUG block-debug-message/ |
| 89 | + expect(stderr.string).not_to match /INFO block-info-message/ |
| 90 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 91 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 92 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 93 | + |
| 94 | + expect(stderr.string).not_to match /DEBUG param-debug-message/ |
| 95 | + expect(stderr.string).not_to match /INFO param-info-message/ |
| 96 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 97 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 98 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
75 | 99 | end |
76 | 100 |
|
77 | 101 | it 'should log all levels above ERROR to console when JBP_LOG_LEVEL set to ERROR', |
78 | 102 | log_level: 'ERROR' do |
79 | 103 |
|
80 | 104 | trigger |
81 | 105 |
|
82 | | - expect(stderr.string).not_to match /DEBUG debug-message/ |
83 | | - expect(stderr.string).not_to match /INFO info-message/ |
84 | | - expect(stderr.string).not_to match /WARN warn-message/ |
85 | | - expect(stderr.string).to match /ERROR error-message/ |
86 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 106 | + expect(stderr.string).not_to match /DEBUG block-debug-message/ |
| 107 | + expect(stderr.string).not_to match /INFO block-info-message/ |
| 108 | + expect(stderr.string).not_to match /WARN block-warn-message/ |
| 109 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 110 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 111 | + |
| 112 | + expect(stderr.string).not_to match /DEBUG param-debug-message/ |
| 113 | + expect(stderr.string).not_to match /INFO param-info-message/ |
| 114 | + expect(stderr.string).not_to match /WARN param-warn-message/ |
| 115 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 116 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
87 | 117 | end |
88 | 118 |
|
89 | 119 | it 'should log FATAL to console when JBP_LOG_LEVEL set to FATAL', |
90 | 120 | log_level: 'FATAL' do |
91 | 121 |
|
92 | 122 | trigger |
93 | 123 |
|
94 | | - expect(stderr.string).not_to match /DEBUG debug-message/ |
95 | | - expect(stderr.string).not_to match /INFO info-message/ |
96 | | - expect(stderr.string).not_to match /WARN warn-message/ |
97 | | - expect(stderr.string).not_to match /ERROR error-message/ |
98 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 124 | + expect(stderr.string).not_to match /DEBUG block-debug-message/ |
| 125 | + expect(stderr.string).not_to match /INFO block-info-message/ |
| 126 | + expect(stderr.string).not_to match /WARN block-warn-message/ |
| 127 | + expect(stderr.string).not_to match /ERROR block-error-message/ |
| 128 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 129 | + |
| 130 | + expect(stderr.string).not_to match /DEBUG param-debug-message/ |
| 131 | + expect(stderr.string).not_to match /INFO param-info-message/ |
| 132 | + expect(stderr.string).not_to match /WARN param-warn-message/ |
| 133 | + expect(stderr.string).not_to match /ERROR param-error-message/ |
| 134 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
99 | 135 | end |
100 | 136 |
|
101 | 137 | it 'should log all levels to console when $DEBUG set', |
102 | 138 | :debug do |
103 | 139 |
|
104 | 140 | trigger |
105 | 141 |
|
106 | | - expect(stderr.string).to match /DEBUG debug-message/ |
107 | | - expect(stderr.string).to match /INFO info-message/ |
108 | | - expect(stderr.string).to match /WARN warn-message/ |
109 | | - expect(stderr.string).to match /ERROR error-message/ |
110 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 142 | + expect(stderr.string).to match /DEBUG block-debug-message/ |
| 143 | + expect(stderr.string).to match /INFO block-info-message/ |
| 144 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 145 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 146 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 147 | + |
| 148 | + expect(stderr.string).to match /DEBUG param-debug-message/ |
| 149 | + expect(stderr.string).to match /INFO param-info-message/ |
| 150 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 151 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 152 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
111 | 153 |
|
112 | 154 | end |
113 | 155 |
|
|
116 | 158 |
|
117 | 159 | trigger |
118 | 160 |
|
119 | | - expect(stderr.string).to match /DEBUG debug-message/ |
120 | | - expect(stderr.string).to match /INFO info-message/ |
121 | | - expect(stderr.string).to match /WARN warn-message/ |
122 | | - expect(stderr.string).to match /ERROR error-message/ |
123 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 161 | + expect(stderr.string).to match /DEBUG block-debug-message/ |
| 162 | + expect(stderr.string).to match /INFO block-info-message/ |
| 163 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 164 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 165 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 166 | + |
| 167 | + expect(stderr.string).to match /DEBUG param-debug-message/ |
| 168 | + expect(stderr.string).to match /INFO param-info-message/ |
| 169 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 170 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 171 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
124 | 172 |
|
125 | 173 | end |
126 | 174 |
|
|
140 | 188 | it 'should log all levels to console when default_log_level set to DEBUG in configuration file' do |
141 | 189 | trigger |
142 | 190 |
|
143 | | - expect(stderr.string).to match /DEBUG debug-message/ |
144 | | - expect(stderr.string).to match /INFO info-message/ |
145 | | - expect(stderr.string).to match /WARN warn-message/ |
146 | | - expect(stderr.string).to match /ERROR error-message/ |
147 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 191 | + expect(stderr.string).to match /DEBUG block-debug-message/ |
| 192 | + expect(stderr.string).to match /INFO block-info-message/ |
| 193 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 194 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 195 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 196 | + |
| 197 | + expect(stderr.string).to match /DEBUG param-debug-message/ |
| 198 | + expect(stderr.string).to match /INFO param-info-message/ |
| 199 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 200 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 201 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
148 | 202 | end |
149 | 203 | end |
150 | 204 |
|
|
159 | 213 | it 'should log all levels above INFO to console when no configuration has been set' do |
160 | 214 | trigger |
161 | 215 |
|
162 | | - expect(stderr.string).not_to match /DEBUG debug-message/ |
163 | | - expect(stderr.string).to match /INFO info-message/ |
164 | | - expect(stderr.string).to match /WARN warn-message/ |
165 | | - expect(stderr.string).to match /ERROR error-message/ |
166 | | - expect(stderr.string).to match /FATAL fatal-message/ |
| 216 | + expect(stderr.string).not_to match /DEBUG block-debug-message/ |
| 217 | + expect(stderr.string).to match /INFO block-info-message/ |
| 218 | + expect(stderr.string).to match /WARN block-warn-message/ |
| 219 | + expect(stderr.string).to match /ERROR block-error-message/ |
| 220 | + expect(stderr.string).to match /FATAL block-fatal-message/ |
| 221 | + |
| 222 | + expect(stderr.string).not_to match /DEBUG param-debug-message/ |
| 223 | + expect(stderr.string).to match /INFO param-info-message/ |
| 224 | + expect(stderr.string).to match /WARN param-warn-message/ |
| 225 | + expect(stderr.string).to match /ERROR param-error-message/ |
| 226 | + expect(stderr.string).to match /FATAL param-fatal-message/ |
167 | 227 | end |
168 | 228 | end |
169 | 229 |
|
|
185 | 245 | end |
186 | 246 |
|
187 | 247 | def trigger |
188 | | - logger.debug { 'debug-message' } |
189 | | - logger.info { 'info-message' } |
190 | | - logger.warn { 'warn-message' } |
191 | | - logger.error { 'error-message' } |
192 | | - logger.fatal { 'fatal-message' } |
| 248 | + logger.debug { 'block-debug-message' } |
| 249 | + logger.info { 'block-info-message' } |
| 250 | + logger.warn { 'block-warn-message' } |
| 251 | + logger.error { 'block-error-message' } |
| 252 | + logger.fatal { 'block-fatal-message' } |
| 253 | + |
| 254 | + logger.debug 'param-debug-message' |
| 255 | + logger.info 'param-info-message' |
| 256 | + logger.warn 'param-warn-message' |
| 257 | + logger.error 'param-error-message' |
| 258 | + logger.fatal 'param-fatal-message' |
193 | 259 | end |
194 | 260 |
|
195 | 261 | end |
0 commit comments