Skip to content

Commit 0d1ebdb

Browse files
authored
Some chore (#296)
* add log-level * chore: adjust clean not found logs * chore: update some logs and docs * chore: add log-level readme
1 parent d365d8d commit 0d1ebdb

6 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ There are BREAKING CHANGES between v0.3.x and v0.4.x, make sure to read the [mig
3333
- [List All Settings](#list-all-settings)
3434
- [Set CKB version](#set-ckb-version)
3535
- [Set Network Proxy](#set-network-proxy)
36+
- [Log-Level](#log-level)
3637
- [Built-in scripts](#built-in-scripts)
3738
- [Accounts](#accounts)
3839
- [About CCC](#about-ccc)
@@ -203,6 +204,8 @@ offckb deploy --type-id --network <devnet/testnet>
203204

204205
Your deployed scripts info will be be listed in the `output-folder-path` which you defined in the command.
205206

207+
Note that upgrades are keyed by the contract‘s artifact name. If you plan to upgrade with `--type-id`, do not rename your contract artifact (e.g. keep `hello-world.bc`). Renaming it makes the offckb unable to find the previous Type ID info from the `output-folder-path` and will create a new Type ID.
208+
206209
### Debug a transaction
207210

208211
If you are interacting the CKB devnet via the proxy RPC server(`localhost:28114`), all the failed transactions will be dumped and recorded so you can debug them later.
@@ -291,6 +294,16 @@ offckb config get proxy
291294
> No Proxy.
292295
```
293296

297+
## Log-Level
298+
299+
You can tweak env `LOG_LEVEL` to control the `offckb` log level.
300+
301+
For example, set `LOG_LEVEL=debug` gives you more outputs of offckb proxy RPC.
302+
303+
```sh
304+
LOG_LEVEL offckb node
305+
```
306+
294307
## Built-in scripts
295308

296309
- [x] xUDT https://github.com/nervosnetwork/rfcs/pull/428

‎src/cmd/clean.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export function clean() {
1616
logger.error((error as Error).message);
1717
}
1818
} else {
19-
logger.info(`${allDevnetDataPath} not found, unable to clean it.`);
19+
logger.info(`Nothing to clean. Devnet data directory ${allDevnetDataPath} not found.`);
2020
}
2121
}

‎src/cmd/deploy.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function deploy(
5252
` 📁 Deployment artifacts will be saved to: ${outputFolder}`,
5353
` 🌐 Network: ${network}`,
5454
` 🔑 Using ${opt.privkey ? 'custom' : 'default'} private key`,
55-
` 🔄 Type ID: ${enableTypeId ? 'enabled (upgradable)' : 'disabled'}`,
55+
` 🔄 Type ID: ${enableTypeId ? 'enabled (upgradable)' : 'disabled (immutable)'}`,
5656
]);
5757

5858
const res = await confirm({

‎src/sdk/ckb.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ export class CKB {
218218
const typeId = deploymentReceipt.cellRecipes[0].typeId;
219219
if (typeId == null) throw new Error("type id in migration file is null, can't be updated.");
220220

221+
logger.info(`Existing Type-ID found:
222+
- Type ID: ${typeId}
223+
(Upgrade keeps the same type-id by consuming the old code Cell and creating a new one.)
224+
`);
221225
const cell = await this.client.getCell(outpoint);
222226
if (cell == null) {
223227
throw new Error('type id cell not found!');

‎src/tools/rpc-proxy.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function createRPCProxy(network: Network, targetRpcUrl: string, port: num
2828
const method = jsonRpcContent.method;
2929
const params = jsonRpcContent.params;
3030
logger.info('RPC Req: ', method);
31+
logger.debug('RPC Params: ', params);
3132

3233
if (method === 'send_transaction') {
3334
const tx = params[0];
@@ -61,10 +62,7 @@ export function createRPCProxy(network: Network, targetRpcUrl: string, port: num
6162

6263
try {
6364
const jsonRpcResponse = JSON.parse(res);
64-
const error = jsonRpcResponse.error;
65-
if (error) {
66-
logger.debug('RPC Response: ', jsonRpcResponse);
67-
}
65+
logger.debug('RPC Response: ', jsonRpcResponse);
6866
} catch (err) {
6967
logger.error('Error parsing JSON-RPC res content:', (err as Error).message);
7068
}

‎src/util/logger.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import winston from 'winston';
22
import chalk from 'chalk';
3+
import process from 'node:process';
34

45
// Define log levels with corresponding chalk colors
56
const levelColors = {
@@ -29,7 +30,7 @@ class UnifiedLogger {
2930

3031
// Create Winston logger with custom format and levels
3132
this.logger = winston.createLogger({
32-
level: options.level || 'info',
33+
level: options.level || process.env.LOG_LEVEL || 'info',
3334
levels: {
3435
error: 0,
3536
warn: 1,

0 commit comments

Comments
 (0)