This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,3 +141,46 @@ test('OPTIONS requests are ignored by default', () => {
141141 } ) ;
142142 } ) ;
143143} ) ;
144+
145+ test ( 'severity field is automatically added to log object' , ( ) => {
146+ const loggerWrites = jest . fn ( ) ;
147+ const logger = loggerFactory ( {
148+ streams : [
149+ {
150+ stream : new stream . Writable ( {
151+ write : ( chunk , encoding , next ) => {
152+ const json = JSON . parse ( chunk ) ;
153+ expect ( json . severity ) . toBe ( 'CRITICAL' ) ;
154+ loggerWrites ( ) ;
155+ next ( ) ;
156+ } ,
157+ } ) ,
158+ } ,
159+ ] ,
160+ } ) ;
161+
162+ logger . fatal ( 'Hello' ) ;
163+ expect ( loggerWrites ) . toBeCalled ( ) ;
164+ } ) ;
165+
166+ test ( 'automatic severity field can be disabled by options' , ( ) => {
167+ const loggerWrites = jest . fn ( ) ;
168+ const logger = loggerFactory ( {
169+ disableStackdriverFormat : true ,
170+ streams : [
171+ {
172+ stream : new stream . Writable ( {
173+ write : ( chunk , encoding , next ) => {
174+ const json = JSON . parse ( chunk ) ;
175+ expect ( json . severity ) . toBe ( undefined ) ;
176+ loggerWrites ( ) ;
177+ next ( ) ;
178+ } ,
179+ } ) ,
180+ } ,
181+ ] ,
182+ } ) ;
183+
184+ logger . fatal ( 'Hello' ) ;
185+ expect ( loggerWrites ) . toBeCalled ( ) ;
186+ } ) ;
You can’t perform that action at this time.
0 commit comments