File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class Client {
2929 constructor ( req , res , connection ) {
3030 this . req = req ;
3131 this . res = res ;
32+ this . ip = req . socket . remoteAddress ;
3233 this . connection = connection ;
3334 }
3435
@@ -52,12 +53,12 @@ class Client {
5253 }
5354
5455 error ( status , err , callId = err ) {
55- const { req : { url } , res, connection } = this ;
56+ const { req : { url } , res, connection, ip } = this ;
5657 const reason = http . STATUS_CODES [ status ] ;
5758 if ( typeof err === 'number' ) err = undefined ;
5859 const error = err ? err . stack : reason ;
59- const msg = status === 403 ? err . message : `${ url } - ${ error } - ${ status } ` ;
60- application . logger . error ( msg ) ;
60+ const msg = status === 403 ? err . message : `${ url } \t ${ error } \t ${ status } ` ;
61+ application . logger . error ( ` ${ ip } \t ${ msg } ` ) ;
6162 const packet = { callback : callId , error : { message : reason } } ;
6263 const result = JSON . stringify ( packet ) ;
6364 if ( connection ) {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ const listener = (req, res) => {
4949 clients . delete ( connection ) ;
5050 } ) ;
5151
52- application . logger . log ( `${ method } \t${ url } ` ) ;
52+ application . logger . log ( `${ client . ip } \t ${ method } \t${ url } ` ) ;
5353 if ( url === '/api' ) {
5454 if ( method !== 'POST' ) {
5555 client . error ( 403 , new Error ( `Forbidden: ${ url } ` ) ) ;
You can’t perform that action at this time.
0 commit comments