Skip to content

Commit 06b0879

Browse files
committed
fix(debug): add timestamp
1 parent 6b8c16d commit 06b0879

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/hooks/debug.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@ import type { HookContext } from '@feathersjs/feathers';
77
*/
88
export 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

0 commit comments

Comments
 (0)