File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,22 @@ import type { HookContext } from '@feathersjs/feathers';
77 */
88export function debug < H extends HookContext = HookContext > ( msg : string , ...fieldNames : string [ ] ) {
99 return ( context : H ) => {
10+ // display timestamp
11+ const now = new Date ( ) ;
12+ console . log (
13+ `${ now . getFullYear ( ) } -${
14+ now . getMonth ( ) + 1
15+ } -${ now . getDate ( ) } ${ now . getHours ( ) } :${ now . getMinutes ( ) } :${ now . getSeconds ( ) } `
16+ ) ;
17+
1018 if ( msg ) {
1119 console . log ( msg ) ;
1220 }
1321
14- console . log ( `${ context . type } : '${ context . path } '.${ context . method } ` ) ;
22+ // display service, method & type of hook (before/after/error)
23+ console . log ( `${ context . type } service('${ context . path } ').${ context . method } ()` ) ;
1524
25+ // display id for get, patch, update & remove
1626 if ( ! [ 'find' , 'create' ] . includes ( context . method ) && 'id' in context ) {
1727 console . log ( 'id:' , context . id ) ;
1828 }
@@ -29,6 +39,7 @@ export function debug<H extends HookContext = HookContext>(msg: string, ...field
2939 console . log ( 'result:' , context . result ) ;
3040 }
3141
42+ // display additional params
3243 const params = context . params || { } ;
3344 console . log ( 'params props:' , Object . keys ( params ) . sort ( ) ) ;
3445
You can’t perform that action at this time.
0 commit comments