Skip to content

Commit

Permalink
feat: add write fn in logger
Browse files Browse the repository at this point in the history
  • Loading branch information
murongg committed Feb 29, 2024
1 parent 94a6246 commit 424370d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/cle-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@antfu/utils": "^0.7.6",
"@ora-io/cle-api": "^0.1.0",
"@ora-io/cle-api": "^0.1.1",
"@ora-io/zkwasm-service-helper": "^1.0.3",
"api": "^6.1.1",
"assemblyscript": "^0.27.12",
Expand Down
12 changes: 12 additions & 0 deletions packages/cle-cli/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class Logger implements CLELogger {
second: 'numeric',
})

private writeCache: string[] = []

constructor(level: LogLevel = 'info', prefix = '[CLE]') {
this.level = level
this.prefix = prefix
Expand Down Expand Up @@ -65,6 +67,16 @@ export class Logger implements CLELogger {
log(...args: any[]): void {
this.info(...args)
}

write(msg: string) {
if (msg === '\n') {
this.debug(this.writeCache.join(''))
this.writeCache = []
}
else {
this.writeCache.push(msg)
}
}
}

export function createLogger(level: LogLevel) {
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 424370d

Please sign in to comment.