@@ -21,7 +21,9 @@ function setupLogging(category, enableCallStack, options) {
21
21
} ;
22
22
} ,
23
23
} ;
24
-
24
+ /**
25
+ * @type {{msg?: string, error(msg:string):void} }
26
+ */
25
27
const fakeConsole = {
26
28
error ( msg ) {
27
29
this . msg = msg ;
@@ -234,7 +236,40 @@ test('logFaces appender', (batch) => {
234
236
235
237
t . end ( ) ;
236
238
} ) ;
239
+ batch . test ( 'eventLayout should error if set incorrectly' , ( t ) => {
240
+ t . throws ( ( ) => {
241
+ setupLogging ( 'myCategory' , false , {
242
+ application : 'LFS-HTTP' ,
243
+ url : 'http://localhost/receivers/rx1' ,
244
+ eventLayout : 'banana' ,
245
+ } ) ;
246
+ } ) ;
247
+ const setup = setupLogging ( 'myCategory' , false , {
248
+ application : 'LFS-HTTP' ,
249
+ url : 'http://localhost/receivers/rx1' ,
250
+ eventLayout : ( event ) => {
251
+ if ( event . data [ 0 ] === 'array' ) {
252
+ return [ ] ;
253
+ }
254
+ if ( event . data [ 0 ] === 'string' ) {
255
+ return 'string' ;
256
+ }
257
+ if ( event . data [ 0 ] === 'object' ) {
258
+ return { } ;
259
+ }
260
+ return undefined ;
261
+ } ,
262
+ } ) ;
263
+ const message =
264
+ 'log4js.logFaces-HTTP Appender eventLayout must be an object' ;
265
+ [ 'array' , 'string' , 'object' ] . forEach ( ( input ) => {
266
+ setup . logger . info ( input ) ;
267
+ t . equal ( setup . fakeConsole . msg , message ) ;
268
+ setup . fakeConsole . msg = undefined ;
269
+ } ) ;
237
270
271
+ t . end ( ) ;
272
+ } ) ;
238
273
batch . test ( 'eventLayout should enable changing the results' , ( t ) => {
239
274
const setup = setupLogging ( 'myCategory' , false , {
240
275
application : 'LFS-HTTP' ,
0 commit comments