From 424370dd78be0a373be7e5699e0f879447695174 Mon Sep 17 00:00:00 2001 From: MuRong Date: Thu, 29 Feb 2024 14:49:45 +0800 Subject: [PATCH] feat: add write fn in logger --- packages/cle-cli/package.json | 2 +- packages/cle-cli/src/logger.ts | 12 ++++++++++++ pnpm-lock.yaml | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/cle-cli/package.json b/packages/cle-cli/package.json index 9c34f57..85161ef 100644 --- a/packages/cle-cli/package.json +++ b/packages/cle-cli/package.json @@ -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", diff --git a/packages/cle-cli/src/logger.ts b/packages/cle-cli/src/logger.ts index 50ed477..01f251a 100644 --- a/packages/cle-cli/src/logger.ts +++ b/packages/cle-cli/src/logger.ts @@ -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 @@ -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) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b982c4..0e23cea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,8 +82,8 @@ importers: specifier: ^0.7.6 version: 0.7.7 '@ora-io/cle-api': - specifier: ^0.1.0 - version: 0.1.0 + specifier: ^0.1.1 + version: 0.1.1 '@ora-io/zkwasm-service-helper': specifier: ^1.0.3 version: 1.0.3 @@ -2006,8 +2006,8 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - /@ora-io/cle-api@0.1.0: - resolution: {integrity: sha512-qlXRYlbRVHEst6hctvaWLtP4IZ31QogEEICaorAU1d6lQVWhZK9edrdP/9BP5uDJV5S5DHpDGqyp3W0Xbeev/w==} + /@ora-io/cle-api@0.1.1: + resolution: {integrity: sha512-bQO4+8Bkcnp+ycepCgXgNpVeO5ZB0GSTCN15P9JUvj1RQTas86P5PjM+mU6CuCdrvqFBZ8i9YKPfrD+vPKhQbQ==} dependencies: '@ethereumjs/rlp': 5.0.2 '@murongg/utils': 0.1.21 @@ -2021,7 +2021,7 @@ packages: js-yaml: 4.1.0 semver: 7.6.0 web3-eth-contract: 1.10.4 - zkwasm-toolchain: 0.0.5 + zkwasm-toolchain: 0.0.6 transitivePeerDependencies: - aws-crt - bufferutil @@ -2046,7 +2046,7 @@ packages: ethers: 6.11.1 form-data: 4.0.0 ts-md5: 1.3.1 - web3subscriber: git@github.com+DelphinusLab/delphinus-web3subscriber/b623f2174498bde8746d2acd43519680c968e466 + web3subscriber: github.com/DelphinusLab/delphinus-web3subscriber/b623f2174498bde8746d2acd43519680c968e466 yargs: 17.6.2 transitivePeerDependencies: - aws-crt @@ -3641,7 +3641,7 @@ packages: /bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} dependencies: - base-x: 3.0.5 + base-x: 3.0.9 dev: false /bson@4.7.2: @@ -9140,12 +9140,12 @@ packages: resolution: {integrity: sha512-3vz0H0jSUCAJcBvEHFxViBS7su0+Ca3fxqO8cePTHwJixRhqE7bp3E/2TDYkV3Oax2k+OmgAmkRnfgam8Svpgg==} dev: false - /zkwasm-toolchain@0.0.5: - resolution: {integrity: sha512-H5dn2WJUWa5qKRYJgGvh7kWVFK7uWuTkh0t9q6Rxr6Z6aIqHz6qf+wBTDjZWYxngVPiOqEs+Yt/7qodPHNatjw==} + /zkwasm-toolchain@0.0.6: + resolution: {integrity: sha512-wQy046r6OMqy5aKKGefXIkb5sYsCi7osQ1cnLBcYfctW6Cs6hg3GOSoqabYNUdRDwuHNeX/ZRoq4jw8VqIoWcw==} dev: false - git@github.com+DelphinusLab/delphinus-web3subscriber/b623f2174498bde8746d2acd43519680c968e466: - resolution: {commit: b623f2174498bde8746d2acd43519680c968e466, repo: git@github.com:DelphinusLab/delphinus-web3subscriber.git, type: git} + github.com/DelphinusLab/delphinus-web3subscriber/b623f2174498bde8746d2acd43519680c968e466: + resolution: {tarball: https://codeload.github.com/DelphinusLab/delphinus-web3subscriber/tar.gz/b623f2174498bde8746d2acd43519680c968e466} name: web3subscriber version: 1.0.0 prepare: true