File tree Expand file tree Collapse file tree 2 files changed +8
-32
lines changed Expand file tree Collapse file tree 2 files changed +8
-32
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- var logger = require ( 'morgan' ) ;
4-
5- var customLogger = function ( tokens , req , res ) {
6- // Don't log on test
7- if ( process . env . NODE_ENV === "test" ) {
8- return ;
9- }
10-
11- // Don't log OPTIONS call, CORS.
12- if ( req . method === "OPTIONS" ) {
13- return ;
14- }
15-
16- var status = res . statusCode ;
17- var color = 32 ;
18- var error = "" ;
19- if ( status >= 500 ) {
20- color = 31 ;
21- error = res . _body ;
22- }
23- else if ( status >= 400 ) {
24- color = 33 ;
25- error = res . _body ;
26- }
27- else if ( status >= 300 ) {
28- color = 36 ;
29- }
30-
31- return '\x1b[90m' + req . method + ' ' + req . url + ' ' + '\x1b[' + color + 'm' + res . statusCode + ' \x1b[90m' + ( new Date ( ) - req . _startTime ) + 'ms' + '\x1b[0m' + ' ' + error ;
3+ var logger = require ( 'restify-logger' ) ;
324
5+ var filter = function filter ( req , res ) {
6+ return process . env . NODE_ENV !== "test" && req . method !== "OPTIONS" ;
337} ;
348
9+ var display = function display ( req , res ) {
10+ return ( req . token && req . token . accountName ) ? req . token . accountName : '???' ;
11+ } ;
3512
36- module . exports = logger ( customLogger ) ;
37- module . exports . customLogger = customLogger ;
13+ module . exports = logger ( filter , display ) ;
Original file line number Diff line number Diff line change 1818 ],
1919 "dependencies" : {
2020 "async" : " ^0.9.0" ,
21- "morgan" : " ^1.3.2" ,
2221 "rarity" : " ^2.1.1" ,
2322 "restify" : " ^2.8.1" ,
23+ "restify-logger" : " ^1.0.0" ,
2424 "supertest" : " ^0.13.0"
2525 },
2626 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments