Skip to content
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

Allow disabling colors in logs #853

Open
jakubgs opened this issue Oct 1, 2021 · 4 comments
Open

Allow disabling colors in logs #853

jakubgs opened this issue Oct 1, 2021 · 4 comments
Assignees
Labels
Config Command line or config file related

Comments

@jakubgs
Copy link
Member

jakubgs commented Oct 1, 2021

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:https://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:https://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:https://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].
@stefantalpalaru
Copy link
Contributor

Try -d:chronicles_colors=none. You might also want -d:chronicles_sinks=json.

@jakubgs
Copy link
Member Author

jakubgs commented Oct 1, 2021

That works, thanks.

@jakubgs jakubgs closed this as completed Oct 1, 2021
@jakubgs
Copy link
Member Author

jakubgs commented Oct 1, 2021

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

@jakubgs jakubgs reopened this Oct 1, 2021
@jlokier
Copy link
Contributor

jlokier commented Oct 15, 2021

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.

@jangko jangko added the Config Command line or config file related label Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Config Command line or config file related
Projects
None yet
Development

No branches or pull requests

4 participants