55
66const Lab = require ( 'lab' ) ;
77const Moment = require ( 'moment' ) ;
8+ // const buildSerialize = require('r7insight_node/lib/serialize');
89
910const Streams = require ( './fixture/streams' ) ;
1011const GoodConsole = require ( '..' ) ;
1112
13+ // const serialize = buildSerialize({});
14+
1215// Declare internals
1316
1417const internals = {
@@ -125,7 +128,7 @@ describe('GoodConsole', () => {
125128 reader . once ( 'end' , ( ) => {
126129
127130 expect ( out . data ) . to . have . length ( 1 ) ;
128- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} \ u001b[32m200\u001b[0m (150ms) \n' ) ;
131+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[32m200\\ u001b[0m","responseTimeMs":150} \n' ) ;
129132 done ( ) ;
130133 } ) ;
131134 } ) ;
@@ -146,7 +149,7 @@ describe('GoodConsole', () => {
146149 reader . once ( 'end' , ( ) => {
147150
148151 expect ( out . data ) . to . have . length ( 1 ) ;
149- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data \ u001b[32m200\u001b[0m (150ms) \n' ) ;
152+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query":"","statusCode":"\\ u001b[32m200\\ u001b[0m","responseTimeMs":150} \n' ) ;
150153 done ( ) ;
151154 } ) ;
152155 } ) ;
@@ -168,7 +171,7 @@ describe('GoodConsole', () => {
168171 reader . once ( 'end' , ( ) => {
169172
170173 expect ( out . data ) . to . have . length ( 1 ) ;
171- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} (150ms) \n' ) ;
174+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"","responseTimeMs":150} \n' ) ;
172175 done ( ) ;
173176 } ) ;
174177 } ) ;
@@ -187,7 +190,7 @@ describe('GoodConsole', () => {
187190 reader . once ( 'end' , ( ) => {
188191
189192 expect ( out . data ) . to . have . length ( 1 ) ;
190- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: post /data {"name":"adam"} 200 (150ms) \n' ) ;
193+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":" post","path":" /data","query": {"name":"adam"},"statusCode": 200,"responseTimeMs":150} \n' ) ;
191194 done ( ) ;
192195 } ) ;
193196 } ) ;
@@ -211,7 +214,7 @@ describe('GoodConsole', () => {
211214 reader . once ( 'end' , ( ) => {
212215
213216 expect ( out . data ) . to . have . length ( 1 ) ;
214- expect ( out . data [ 0 ] ) . to . be . equal ( `${ date } , (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} \ u001b[32m200\u001b[0m (150ms) \n` ) ;
217+ expect ( out . data [ 0 ] ) . to . be . equal ( `{"timestamp":" ${ date } ","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[32m200\\ u001b[0m","responseTimeMs":150} \n` ) ;
215218 done ( ) ;
216219 } ) ;
217220 } ) ;
@@ -233,7 +236,7 @@ describe('GoodConsole', () => {
233236 reader . once ( 'end' , ( ) => {
234237
235238 expect ( out . data ) . to . have . length ( 1 ) ;
236- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;34mhead\u001b[0m /data {"name":"adam"} \ u001b[32m200\u001b[0m (150ms) \n' ) ;
239+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;34mhead\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[32m200\\ u001b[0m","responseTimeMs":150} \n' ) ;
237240 done ( ) ;
238241 } ) ;
239242 } ) ;
@@ -255,7 +258,7 @@ describe('GoodConsole', () => {
255258 reader . once ( 'end' , ( ) => {
256259
257260 expect ( out . data ) . to . have . length ( 1 ) ;
258- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} \ u001b[31m599\u001b[0m (150ms) \n' ) ;
261+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[31m599\\ u001b[0m","responseTimeMs":150} \n' ) ;
259262 done ( ) ;
260263 } ) ;
261264 } ) ;
@@ -277,7 +280,7 @@ describe('GoodConsole', () => {
277280 reader . once ( 'end' , ( ) => {
278281
279282 expect ( out . data ) . to . have . length ( 1 ) ;
280- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} \ u001b[33m418\u001b[0m (150ms) \n' ) ;
283+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[33m418\\ u001b[0m","responseTimeMs":150} \n' ) ;
281284 done ( ) ;
282285 } ) ;
283286 } ) ;
@@ -299,7 +302,7 @@ describe('GoodConsole', () => {
299302 reader . once ( 'end' , ( ) => {
300303
301304 expect ( out . data ) . to . have . length ( 1 ) ;
302- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1458264811279:localhost:16014:ilx17kv4:10001) [ response] http://localhost:61253: \ u001b[1;33mpost\u001b[0m /data {"name":"adam"} \ u001b[36m304\u001b[0m (150ms) \n' ) ;
305+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" response"],"method":"\\ u001b[1;33mpost\\ u001b[0m","path":" /data","query": {"name":"adam"},"statusCode":"\\ u001b[36m304\\ u001b[0m","responseTimeMs":150} \n' ) ;
303306 done ( ) ;
304307 } ) ;
305308 } ) ;
@@ -323,7 +326,7 @@ describe('GoodConsole', () => {
323326 reader . once ( 'end' , ( ) => {
324327
325328 expect ( out . data ) . to . have . length ( 20 ) ;
326- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, [ ops] memory: 29Mb, uptime (seconds): 6, load: [1.650390625,1.6162109375,1.65234375]\n' ) ;
329+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" ops"],"memoryMb":29,"uptimeSeconds":6," load": [1.650390625,1.6162109375,1.65234375]} \n' ) ;
327330 done ( ) ;
328331 } ) ;
329332 } ) ;
@@ -345,7 +348,7 @@ describe('GoodConsole', () => {
345348 reader . once ( 'end' , ( ) => {
346349
347350 expect ( out . data ) . to . have . length ( 1 ) ;
348- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1419005623332:new-host.local:48767:i3vrb3z7:10000) [ error, user, info] message: Just a simple error, stack: Error: Just a simple Error\n' ) ;
351+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" error"," user"," info"]," message":" Just a simple error"," stack":" Error: Just a simple Error"} \n' ) ;
349352 done ( ) ;
350353 } ) ;
351354 } ) ;
@@ -367,7 +370,7 @@ describe('GoodConsole', () => {
367370 reader . once ( 'end' , ( ) => {
368371
369372 expect ( out . data ) . to . have . length ( 1 ) ;
370- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, (1419005623332:new-host.local:48767:i3vrb3z7:10000) [ request, user, info] data: you made a request\n' ) ;
373+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" request"," user"," info"]," data":" you made a request"} \n' ) ;
371374 done ( ) ;
372375 } ) ;
373376 } ) ;
@@ -389,7 +392,7 @@ describe('GoodConsole', () => {
389392 reader . once ( 'end' , ( ) => {
390393
391394 expect ( out . data ) . to . have . length ( 1 ) ;
392- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, [ request, user, info] data: you made a default\n' ) ;
395+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" request"," user"," info"]," data":" you made a default"} \n' ) ;
393396 done ( ) ;
394397 } ) ;
395398 } ) ;
@@ -411,7 +414,7 @@ describe('GoodConsole', () => {
411414 reader . once ( 'end' , ( ) => {
412415
413416 expect ( out . data ) . to . have . length ( 1 ) ;
414- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, [ request, user, info] data: (none)\n' ) ;
417+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" request"," user"," info"]," data":" (none)"} \n' ) ;
415418 done ( ) ;
416419 } ) ;
417420 } ) ;
@@ -433,7 +436,7 @@ describe('GoodConsole', () => {
433436 reader . once ( 'end' , ( ) => {
434437
435438 expect ( out . data ) . to . have . length ( 1 ) ;
436- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, [ request, user, info] data: {"hello":"world"}\n' ) ;
439+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" request"," user"," info"]," data": {"hello":"world"} }\n' ) ;
437440 done ( ) ;
438441 } ) ;
439442 } ) ;
@@ -455,7 +458,7 @@ describe('GoodConsole', () => {
455458 reader . once ( 'end' , ( ) => {
456459
457460 expect ( out . data ) . to . have . length ( 1 ) ;
458- expect ( out . data [ 0 ] ) . to . be . equal ( '160318/013330.957, [ request, test] data: you made a default\n' ) ;
461+ expect ( out . data [ 0 ] ) . to . be . equal ( '{"timestamp":" 160318/013330.957","tags":[" request"," test"]," data":" you made a default"} \n' ) ;
459462 done ( ) ;
460463 } ) ;
461464 } ) ;
@@ -477,7 +480,9 @@ describe('GoodConsole', () => {
477480 reader . once ( 'end' , ( ) => {
478481
479482 expect ( out . data ) . to . have . length ( 1 ) ;
480- expect ( out . data [ 0 ] . split ( '\n' ) [ 0 ] ) . to . be . equal ( '160318/013330.957, [request,user,info] message: you logged an error, stack: Error: you logged an error' ) ;
483+ const logObject = JSON . parse ( out . data [ 0 ] ) ;
484+ logObject . stack = logObject . stack . split ( '\n' ) [ 0 ] ;
485+ expect ( JSON . stringify ( logObject ) ) . to . be . equal ( '{"timestamp":"160318/013330.957","tags":["request","user","info"],"message":"you logged an error","stack":"Error: you logged an error"}' ) ;
481486 done ( ) ;
482487 } ) ;
483488 } ) ;
0 commit comments