Skip to content

Commit

Permalink
feat(logger): add logStep method to logger
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Sep 28, 2024
1 parent 1f6bd71 commit 860aeed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/logger/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export const createLogger = (domain: string, debugMode = defaultDebugMode): Alwa

logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset),

logStep: console.debug.bind(console, _keySection + '.%s() -> %s', styleScope, domain, _style.reset),

logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset),

incident: platformInfo.isCli
Expand Down
19 changes: 18 additions & 1 deletion packages/logger/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,24 @@ export interface AlwatrLogger {
* }
* ```
*/
logMethodArgs?(method: string, args: unknown): void;

/**
* `console.debug` steps in a method.
*
* Example:
*
* ```ts
* function myMethod () {
* logger.logMethod?.('myMethod');
* ...
* logger.logStep?.('myMethod', 'step1');
* ...
* logger.logStep?.('myMethod', 'step2');
* ...
* }
* ```
*/
logStep?(methodName: string, stepName: string, props?: unknown): void;

/**
* `console.debug` function or method calls with arguments.
Expand Down

0 comments on commit 860aeed

Please sign in to comment.