@@ -59,6 +59,38 @@ describe('info logs', () => {
59
59
) ;
60
60
expect ( log ) ;
61
61
} ) ;
62
+
63
+ it ( 'info logs should interpolate json' , async ( ) => {
64
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
65
+ winstonLoggerAdapter . log ( 'info' , 'testing info logs with %j' , { hello : 'world' } ) ;
66
+ const results = await winstonLoggerAdapter . query ( {
67
+ from : new Date ( Date . now ( ) - 500 ) ,
68
+ size : 100 ,
69
+ level : 'info' ,
70
+ order : 'desc' ,
71
+ } ) ;
72
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
73
+ const log = results . find (
74
+ x => x . message === 'testing info logs with {"hello":"world"}'
75
+ ) ;
76
+ expect ( log ) ;
77
+ } ) ;
78
+
79
+ it ( 'info logs should interpolate number' , async ( ) => {
80
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
81
+ winstonLoggerAdapter . log ( 'info' , 'testing info logs with %d' , 123 ) ;
82
+ const results = await winstonLoggerAdapter . query ( {
83
+ from : new Date ( Date . now ( ) - 500 ) ,
84
+ size : 100 ,
85
+ level : 'info' ,
86
+ order : 'desc' ,
87
+ } ) ;
88
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
89
+ const log = results . find (
90
+ x => x . message === 'testing info logs with 123'
91
+ ) ;
92
+ expect ( log ) ;
93
+ } ) ;
62
94
} ) ;
63
95
64
96
describe ( 'error logs' , ( ) => {
@@ -113,6 +145,38 @@ describe('error logs', () => {
113
145
) ;
114
146
expect ( log ) ;
115
147
} ) ;
148
+
149
+ it ( 'error logs should interpolate json' , async ( ) => {
150
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
151
+ winstonLoggerAdapter . log ( 'error' , 'testing error logs with %j' , { hello : 'world' } ) ;
152
+ const results = await winstonLoggerAdapter . query ( {
153
+ from : new Date ( Date . now ( ) - 500 ) ,
154
+ size : 100 ,
155
+ level : 'error' ,
156
+ order : 'desc' ,
157
+ } ) ;
158
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
159
+ const log = results . find (
160
+ x => x . message === 'testing error logs with {"hello":"world"}'
161
+ ) ;
162
+ expect ( log ) ;
163
+ } ) ;
164
+
165
+ it ( 'error logs should interpolate number' , async ( ) => {
166
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
167
+ winstonLoggerAdapter . log ( 'error' , 'testing error logs with %d' , 123 ) ;
168
+ const results = await winstonLoggerAdapter . query ( {
169
+ from : new Date ( Date . now ( ) - 500 ) ,
170
+ size : 100 ,
171
+ level : 'error' ,
172
+ order : 'desc' ,
173
+ } ) ;
174
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
175
+ const log = results . find (
176
+ x => x . message === 'testing error logs with 123'
177
+ ) ;
178
+ expect ( log ) ;
179
+ } ) ;
116
180
} ) ;
117
181
118
182
describe ( 'verbose logs' , ( ) => {
@@ -180,4 +244,38 @@ describe('verbose logs', () => {
180
244
) ;
181
245
expect ( log ) ;
182
246
} ) ;
247
+
248
+ it ( 'verbose logs should interpolate json' , async ( ) => {
249
+ await reconfigureServer ( { verbose : true } ) ;
250
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
251
+ winstonLoggerAdapter . log ( 'verbose' , 'testing verbose logs with %j' , { hello : 'world' } ) ;
252
+ const results = await winstonLoggerAdapter . query ( {
253
+ from : new Date ( Date . now ( ) - 500 ) ,
254
+ size : 100 ,
255
+ level : 'verbose' ,
256
+ order : 'desc' ,
257
+ } ) ;
258
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
259
+ const log = results . find (
260
+ x => x . message === 'testing verbose logs with {"hello":"world"}'
261
+ ) ;
262
+ expect ( log ) ;
263
+ } ) ;
264
+
265
+ it ( 'verbose logs should interpolate number' , async ( ) => {
266
+ await reconfigureServer ( { verbose : true } ) ;
267
+ const winstonLoggerAdapter = new WinstonLoggerAdapter ( ) ;
268
+ winstonLoggerAdapter . log ( 'verbose' , 'testing verbose logs with %d' , 123 ) ;
269
+ const results = await winstonLoggerAdapter . query ( {
270
+ from : new Date ( Date . now ( ) - 500 ) ,
271
+ size : 100 ,
272
+ level : 'verbose' ,
273
+ order : 'desc' ,
274
+ } ) ;
275
+ expect ( results . length > 0 ) . toBeTruthy ( ) ;
276
+ const log = results . find (
277
+ x => x . message === 'testing verbose logs with 123'
278
+ ) ;
279
+ expect ( log ) ;
280
+ } ) ;
183
281
} ) ;
0 commit comments