nimbus-eth1
nimbus-eth1 copied to clipboard
Allow disabling colors in logs
I'm configuring this client to run under Systemd and the logs I'm seeing in a file created by rsyslog include colors:
#033[96mINF#033[0m 2021-10-01 10:04:19.350+00:00 #033[1mRLPx listener up #033[0m #033[96mtid#033[0m=#033[94m486849#033[0m #033[96mfile#033[0m=#033[94mp2p.nim:91#033[0m #033[96mself#033[0m=#033[94menode://6d607f9f6599df50fdc7be991bc43c965437d152446c90644acedee43f2cf7214af27c53be2ec66769baf51707a2a9b8096796fde134940db3ba074252360ab2@0.0.0.0:30303#033[0m
#033[96mINF#033[0m 2021-10-01 10:04:57.299+00:00 #033[1mRLPx listener up #033[0m #033[96mtid#033[0m=#033[94m486912#033[0m #033[96mfile#033[0m=#033[94mp2p.nim:91#033[0m #033[96mself#033[0m=#033[94menode://38d073f28503f1a4f59a2cd64e0f4dca78bcd1092fbfa121fb9df3d9ddf5fc3631290e9c6e484fc717fec70a00dfaa93510519cc0103de197180717a7cbe57de@0.0.0.0:30303#033[0m
#033[96mINF#033[0m 2021-10-01 10:05:51.258+00:00 #033[1mStarting JSON-RPC HTTP server #033[0m topics="#033[93mJSONRPC-HTTP-SERVER#033[0m" #033[96mtid#033[0m=#033[94m486912#033[0m #033[96mfile#033[0m=#033[94mhttpserver.nim:213#033[0m #033[96murl#033[0m=#033[94mhttp://127.0.0.1:8545#033[0m
#033[96mINF#033[0m 2021-10-01 10:05:51.263+00:00 #033[1mStarting metrics HTTP server #033[0m #033[96mtid#033[0m=#033[94m486912#033[0m #033[96mfile#033[0m=#033[94mnimbus.nim:190#033[0m #033[96maddress#033[0m=#033[94m127.0.0.1#033[0m #033[96mport#033[0m=#033[94m9093#033[0m
And I see no flag to disable colors:
LOGGING AND DEBUGGING OPTIONS:
--log-level Sets the log level for process and topics (TRACE, DEBUG, INFO, NOTICE, WARN,
ERROR, FATAL) [=INFO].
--log-file Specifies a path for the written Json log file.
--log-metrics Enable metrics logging [=false].
--log-metrics-interval Interval at which to log metrics, in seconds [=10].
Try -d:chronicles_colors=none
. You might also want -d:chronicles_sinks=json
.
That works, thanks.
Actually, -d:chronicles_colors=none
works as expected, but -d:chronicles_sinks=json
fails with:
[NimScript] exec: nim c --out:build/nimbus -d:chronicles_log_level=TRACE -d:chronicles_sinks=json --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:release nimbus/nimbus.nim
/data/nimbus-eth1-mainnet-master/repo/nimbus/vm_compile_info.nim(23, 10) Warning: *** Compiling with nimvm enabled [User]
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-eth/eth/p2p/kademlia.nim(198, 10) template/generic instantiation of `warn` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-chronicles/chronicles.nim(363, 10) template/generic instantiation of `log` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-chronicles/chronicles/log_output.nim(86, 65) template/generic instantiation of `expandItIMPL` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-chronicles/chronicles/log_output.nim(677, 10) template/generic instantiation of `[]=` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-chronicles/chronicles/log_output.nim(652, 15) template/generic instantiation of `writeField` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(72, 4) template/generic instantiation of `writeValue` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(159, 17) template/generic instantiation of `writeValue` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(219, 10) template/generic instantiation of `enumInstanceSerializedFields` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(222, 8) template/generic instantiation of `writeFieldIMPL` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-serialization/serialization/object_serialization.nim(192, 9) template/generic instantiation of `writeValue` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(219, 10) template/generic instantiation of `enumInstanceSerializedFields` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(222, 8) template/generic instantiation of `writeFieldIMPL` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-serialization/serialization/object_serialization.nim(192, 9) template/generic instantiation of `writeValue` from here
/data/nimbus-eth1-mainnet-master/repo/vendor/nim-json-serialization/json_serialization/writer.nim(228, 12) Error: Failed to convert to JSON an unsupported type: PublicKey
stack trace: (most recent call last)
/data/nimbus-eth1-mainnet-master/repo/vendor/nimbus-build-system/vendor/Nim/lib/system/nimscript.nim(416, 18)
/data/nimbus-eth1-mainnet-master/repo/nimbus.nimble(52, 15) nimbusTask
/data/nimbus-eth1-mainnet-master/repo/nimbus.nimble(30, 8) buildBinary
/data/nimbus-eth1-mainnet-master/repo/vendor/nimbus-build-system/vendor/Nim/lib/system/nimscript.nim(260, 7) exec
/data/nimbus-eth1-mainnet-master/repo/vendor/nimbus-build-system/vendor/Nim/lib/system/nimscript.nim(260, 7) Error: unhandled exception: FAILED: nim c --out:build/nimbus -d:chronicles_log_level=TRACE -d:chronicles_sinks=json --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:release nimbus/nimbus.nim [OSError]
make: *** [Makefile:110: nimbus] Error 1
Error: Failed to convert to JSON an unsupported type: PublicKey
For my purposes I decided to keep the colours in log files. The files can be viewed with less -R
; I have LESS=R
in my environment to enable that all the time. The terminal codes do interfere with grep
though.
Thanks for the JSON report. We don't use the JSON logging in practice, and most of the "format object as text" functions are defined with Nim $(..)
, which the JSON logging doesn't use. That explains the PublicKey
problem. There may be others, even if it compiles.