-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes to log output lines and log setup #152
Conversation
api/server.go
Outdated
Str("id", fmt.Sprintf("%v", body["id"])). | ||
Str("result", fmt.Sprintf("%v", body["result"])). | ||
Float64("id", body["id"].(float64)). | ||
Fields(body["result"]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body["result"]
is not always a container value (e.g. an array or map). It can also be a scalar value, e.g.
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x2"
}
So the Fields
will not work for this case.
Co-authored-by: Ardit Marku <[email protected]>
…lt value for rpc-host flag
@franklywatson Here is the end result of how logs will look like: API request log line: {
"level": "debug",
"component": "API",
"url": "/",
"id": 10,
"method": "eth_syncing",
"params": [],
"is-ws": false,
"time": "2024-03-11T18:37:27+02:00",
"message": "API request"
} API response with {
"level": "debug",
"component": "API",
"id": 10,
"result": false,
"time": "2024-03-11T18:37:27+02:00",
"message": "API response"
} API response with {
"level": "debug",
"component": "API",
"id": 1,
"result": "0xe414f90fea2aebd75e8c0b3b6a4a0c9928e86c16ea724343d884f40bfe2c4c6b",
"time": "2024-03-11T18:48:05+02:00",
"message": "API response"
} API response with {
"level": "debug",
"component": "API",
"id": 7,
"result": null,
"time": "2024-03-11T18:38:50+02:00",
"message": "API response"
} API response with {
"level": "debug",
"component": "API",
"id": 7,
"result": {
"hash": "0x1c501d129b02678731e97461ee37ba69b7b1f76cb0e69599aecd2c05d309294f",
"number": "0x2",
"parentHash": "0x0e67c87db388a7ac0ce4922ccc225793fa93cf6b701ae28c3654b2c1ab780924",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactions": [
"0x1063764dc57cbc6c73051a74d593efd40c6e0999ba05003de631d7ce10806808"
]
},
"time": "2024-03-11T18:38:33+02:00",
"message": "API response"
} API response with error: {
"level": "debug",
"component": "API",
"error": {
"code": -32602,
"message": "invalid argument 0: hex string without 0x prefix"
},
"id": 7,
"time": "2024-03-11T18:39:18+02:00",
"message": "API response"
} |
Looks great thanks! |
Log lines were not being output to JSON the same way as they were being output to stdout so needed to adjust the way logged values were being stringified.
Also removed the --log-output option to always use stdout since it gets confusing when looking at server logs in grafana which show both stdout and stderr; want to keep clean separation between them