status-im / nimbus-eth2

Nim implementation of the Ethereum Beacon Chain
https://nimbus.guide
Other
543 stars 233 forks source link

`--log-file` option and colors missing from binary builds #2326

Closed arnetheduck closed 3 years ago

arnetheduck commented 3 years ago

v1.0.7, linux

[arnetheduck@tempus build]$ ./nimbus_beacon_node --log-file=xx.log
WRN 2021-02-16 09:17:12.348+01:00 The --log-file option is not active in the current build tid=215907 file=nimbus_binary_common.nim:62

looks like these were built as a server version?

stefantalpalaru commented 3 years ago

Yes, I restricted the logging to stdout and removed the colours, to avoid double-logging surprises and facilitate log analysis:

https://github.com/status-im/nimbus-eth2/blob/596b8c6009ce893bbafcbefc74bc3edeecf967ce/docker/dist/entry_point.sh#L61

I don't know how to enable an optional log file without having it always on.

arnetheduck commented 3 years ago

we have users using the --log-file option, so it needs to be present in binary builds. @zah is adding dynamic color options as well.

I don't know how to enable an optional log file without having it always on.

this is what the default build does, so it must be possible somehow?

stefantalpalaru commented 3 years ago

this is what the default build does

No, the default build will always write a log file in the current working directory, which is a potential blocker when you use an init/service script that doesn't ensure a writeable workdir - and also a terrible idea to dump huge logs on an unsuspecting user.

zah commented 3 years ago

I can look into this for the next release. The --log-file option used to work correctly in the past (if not specified, no log file created).

jakubgs commented 3 years ago

I encountered this issue when running on Windows in https://github.com/status-im/infra-nimbus/issues/59:

{"lvl":"WRN","ts":"2021-07-18 17:05:15.093+00:00","msg":"The --log-file option is not active in the current build","tid":2304,"file":"nimbus_binary_common.nim:71"}

And as I can see it logs to the pwd of the process.

stefantalpalaru commented 3 years ago

it logs to the pwd of the process

That's by default, and I disabled it for distributed binaries with -d:chronicles_sinks=textlines (a "sink" is a logging output and elsewhere that is set to textlines,json[file]).

Defining testnet_servers_image also disables it: https://github.com/status-im/nimbus-eth2/blob/stable/beacon_chain/nimbus_beacon_node.nim.cfg