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';
7
7
*/
8
8
export function debug < H extends HookContext = HookContext > ( msg : string , ...fieldNames : string [ ] ) {
9
9
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
+
10
18
if ( msg ) {
11
19
console . log ( msg ) ;
12
20
}
13
21
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 } ()` ) ;
15
24
25
+ // display id for get, patch, update & remove
16
26
if ( ! [ 'find' , 'create' ] . includes ( context . method ) && 'id' in context ) {
17
27
console . log ( 'id:' , context . id ) ;
18
28
}
@@ -29,6 +39,7 @@ export function debug<H extends HookContext = HookContext>(msg: string, ...field
29
39
console . log ( 'result:' , context . result ) ;
30
40
}
31
41
42
+ // display additional params
32
43
const params = context . params || { } ;
33
44
console . log ( 'params props:' , Object . keys ( params ) . sort ( ) ) ;
34
45
You can’t perform that action at this time.
0 commit comments