Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Unless you need to set a non-default value, it is recommended to only populate o
| `HEDERA_NETWORK` | "" | Which network to connect to. Automatically populates the main node & mirror node endpoints. Can be `previewnet`, `testnet`, `mainnet` or a map of network IPs -> node accountIds e.g. `{"127.0.0.1:50211":"0.0.3"}` |
| `INPUT_SIZE_LIMIT` | "1mb" | The [koa-jsonrpc](https://github.com/Bitclimb/koa-jsonrpc) maximum size allowed for requests |
| `LOG_LEVEL` | "trace" | The logging level for the application. Valid values are `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. |
| `LOG_FORMAT` | "pretty" | The logging output format. Valid values are `pretty` (human-readable with colors) and `json` (structured JSON format for log aggregation systems). |
| `MAX_BLOCK_RANGE` | "5" | The maximum block number greater than the mirror node's latest block to query for |
| `OPERATOR_ID_MAIN` | "" | Operator account ID used to pay for transactions. In `S.R.N` format, e.g. `0.0.1001`. |
| `OPERATOR_KEY_FORMAT` | "DER" | Operator private key format. Valid types are `DER`, `HEX_ECDSA`, or `HEX_ED25519` |
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

5 changes: 5 additions & 0 deletions packages/config-service/src/services/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ const _CONFIG = {
required: false,
defaultValue: 'trace',
},
LOG_FORMAT: {
type: 'string',
required: false,
defaultValue: 'pretty',
},
MAX_BLOCK_RANGE: {
type: 'number',
required: false,
Expand Down
23 changes: 14 additions & 9 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { spec } from './koaJsonRpc/lib/RpcError';
// https://nodejs.org/api/async_context.html#asynchronous-context-tracking
const context = new AsyncLocalStorage<{ requestId: string }>();

const logFormat = ConfigService.get('LOG_FORMAT');

const mainLogger = pino({
name: 'hedera-json-rpc-relay',
level: ConfigService.get('LOG_LEVEL'),
Expand All @@ -26,16 +28,19 @@ const mainLogger = pino({
const store = context.getStore();
return store ? { requestId: `[Request ID: ${store.requestId}] ` } : {};
},
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
messageFormat: '{requestId}{msg}',
// Ignore one or several keys, nested keys are supported with each property delimited by a dot character (`.`)
ignore: 'requestId',
// Only use pino-pretty when LOG_FORMAT is set to 'pretty' (default)
...(logFormat === 'pretty' && {
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: true,
messageFormat: '{requestId}{msg}',
// Ignore one or several keys, nested keys are supported with each property delimited by a dot character (`.`)
ignore: 'requestId',
},
},
},
}),
});

export const logger = mainLogger.child({ name: 'rpc-server' });
Expand Down
Loading