More readable logging message
- Dominant language
- Go
- Stars
- 44
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
Current log message like below:
```
EROR[11-05|17:09:50] failed to broadcast module=network node=GDTE.6RAE error="Post http://localhost:2824/node/ballot: dial tcp [::1]:2824: connect: connection refused" validator=node4 message="{\n \"H\": {\n \"hash\": \"6q4eecYws2EP4RfMonFMg7FKg2q2vw48mHS4LSopV6GL\",\n \"signature\": \"5uNtuC1FWKU6sM5jqr7CLJRysFyK2mfoTnHaXcCRrC48vt51QyYxZJQmCVE1nfAzA1vLHDZ7D2vbwPqP5Ewtuvhy\",\n \"proposer_signature\": \"3riy7VEi3QroUqj6MUFJ5ts5AiDkxWNvBRqM1gaGF7fpD2APQvLiVCxMqsNXYTWW6HTcWRn2J3rV9thECudcBdnB\"\n },\n \"B\": {\n \"confirmed\": \"2018-11-05T17:09:50.465888000+09:00\",\n \"proposed\": {\n \"confirmed\": \"2018-11-05T17:09:50.461757000+09:00\",\n \"proposer\": \"GCDCXYUTLFOZSRQ4K6DTZ3R7ZJMD6CHVL3ZM7KGOG52NOTNHWBKYPCIO\",\n \"voting_basis\": {\n \"round\": 0,\n \"height\": 85,\n \"block-hash\": \"3a9Hx9GVJdgA8DHqbSnVVtH5qhNj4pvouvZnXkRpX4XX\",\n \"total-txs\": 85,\n \"total-ops\": 170\n },\n \"transactions\": [],\n \"proposer_transaction\": {\n \"H\": {\n \"version\": \"\",\n \"created\": \"2018-11-05T17:09:50.461369000+09:00\",\n \"signature\": \"35dX4AVTQMw8xRo7oPenkHHbiR1yybESP86b2o22dVedUA8PFVeX3keUkHF9e9Fh1uLYrPi8EsujTCHXtqatfcNZ\"\n },\n \"B\": {\n \"source\": \"GAYGELM74WJMKSLDN5YP2VAMP64WC4IXIGICUNK2SCVIT7KPTLY7M3MW\",\n \"fee\": \"0\",\n \"sequence_id\": 0,\n \"operations\": [\n {\n \"H\": {\n \"type\": \"collect-tx-fee\"\n },\n \"B\": {\n \"target\": \"GDYIHSHMDXJ4MXE35N4IMNC2X3Q3F665C5EX2JWHHCUW2PCFVXIFEE2C\",\n \"amount\": \"0\",\n \"txs\": 0,\n \"block-height\": 85,\n \"block-hash\": \"3a9Hx9GVJdgA8DHqbSnVVtH5qhNj4pvouvZnXkRpX4XX\",\n \"total-txs\": 85,\n \"total-ops\": 0\n }\n },\n {\n \"H\": {\n \"type\": \"inflation\"\n },\n \"B\": {\n \"target\": \"GDYIHSHMDXJ4MXE35N4IMNC2X3Q3F665C5EX2JWHHCUW2PCFVXIFEE2C\",\n \"amount\": \"1000000000000\",\n \"initial_balance\": \"10000000000000000000\",\n \"ratio\": \"0.00000010000000000\",\n \"block-height\": 85,\n \"block-hash\": \"3a9Hx9GVJdgA8DHqbSnVVtH5qhNj4pvouvZnXkRpX4XX\",\n \"total-txs\": 85,\n \"total-ops\": 0\n }\n }\n ]\n }\n }\n },\n \"source\": \"GDTEPFWEITKFHSUO44NQABY2XHRBBH2UBVGJ2ZJPDREIOL2F6RAEBJE4\",\n \"state\": 3,\n \"vote\": \"EXPIRED\",\n \"reason\": null\n }\n}" response= caller=validator_connection_manager.go:211
```
If we print with message field like below:
```
infoLog.Info(fmt.Sprintf("NewBlock created block:%s", blk),
"height", blk.Height,
"round", blk.Round,
"timestamp", blk.Timestamp,
"total-txs", blk.TotalTxs,
"total-ops", blk.TotalOps,
"proposer", blk.Proposer,
)
```
Log message are printed like below:
```
INFO[11-05|18:13:00] NewBlock created block:{
"version": 0,
"prev_block_hash": "A9FV93gnusWcDMrkptnKWSzZjat1KFm4r5vZtygN5hsj",
"transactions_root": "GTWvdpUnvATYmVsm6crKB9h7WQEM4D5AsWJxFd7ZxNTV",
"timestamp": "2018-11-05T18:13:00.874422+09:00",
"height": 127,
"total-txs": 127,
"total-ops": 254,
"transactions": null,
"proposer_transaction": "FY84F4oby2uG6B19H8b6zQHQnSb7FEb9EDoGffFUvTov",
"hash": "4isPM95agepDSLAiP1djQb4anyzJdoU6zsWSMC8331wd",
"confirmed": "2018-11-05T18:13:00.863035000+09:00",
"proposer": "GDIRF4UWPACXPPI4GW7CMTACTCNDIKJEHZK44RITZB4TD3YUM6CCVNGJ",
"round": 0
} module=noderunner node=GCDC.WBKY height=127 round=0 timestamp=2018-11-05T18:13:00+0900 total-txs=127 total-ops=254 proposer=GDIRF4UWPACXPPI4GW7CMTACTCNDIKJEHZK44RITZB4TD3YUM6CCVNGJ caller=checker.go:651
```
But, It is bascially multiline log message.. We need to figure out how to delimite each of log messages.
It is not important issue,but Do you have idea for readable log message? :->
Contributor guide
Research direction
Start by reading validator_connection_manager.go at line 211 and checker.go at line 651, then trace the logger used by the shown Info call. Define and test a readable representation for multiline log messages; done means the affected examples are unambiguous in output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100