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

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

Closed
arnetheduck opened this issue Feb 16, 2021 · 6 comments
Closed

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

arnetheduck opened this issue Feb 16, 2021 · 6 comments
Assignees

Comments

@arnetheduck
Copy link
Member

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
Copy link
Contributor

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

NIMFLAGS="-d:disableMarchNative -d:chronicles_sinks=textlines -d:chronicles_colors=none" \

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

@arnetheduck
Copy link
Member Author

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
Copy link
Contributor

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
Copy link
Contributor

zah commented Feb 16, 2021

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
Copy link
Member

jakubgs commented Jul 19, 2021

I encountered this issue when running on Windows in status-im/infra-nimbus#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
Copy link
Contributor

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

arnetheduck added a commit that referenced this issue Oct 28, 2021
With this PR, released binaries will no longer write log files by default!

* add --log-stdout option to control logging to stdout (colors, json)
* detect tty:s vs redirected logs and log accordingly
* add option to disable log colors
* simplify several "common" logs, showing the most important information earlier and more clearly
* remove line numbers / file information / tid - these take up space and are of little use to end users
  * still enabled in debug builds and tools
* remove `testnet_servers_image` compile-time option
  * server images, released binaries and compile-from-source now offers the same behaviour
* fixes #2326
* fixes #1794
* fixes #2685
* reshuffle some beacon node init code
* remove instanteneous block speed from sync message, keeping only average

before:

```
INF 2021-10-28 16:45:59.000+02:00 Slot start                                 topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:884 lastSlot=2384027 wallSlot=2384028 delay=461us84ns peers=0 head=75a10ee5:3348 headEpoch=104 finalized=cd6804ba:3264 finalizedEpoch=102 sync="wwwwwwwwww:0:0.0000:0.0000:00h00m (3348)"
INF 2021-10-28 16:45:59.046+02:00 Slot end                                   topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:821 slot=2384028 nextSlot=2384029 head=75a10ee5:3348 headEpoch=104 finalizedHead=cd6804ba:3264 finalizedEpoch=102 nextAttestationSlot=-1 nextProposalSlot=-1 nextActionWait=n/a
```

after:

```
INF 2021-10-28 22:43:23.033+02:00 Slot start                                 topics="beacnde" slot=2385815 epoch=74556 sync="DDPDDPUDDD:10:5.2258:01h19m (2361088)" peers=37 head=eacd2dae:2361096 finalized=73782:a4751487 delay=33ms687us715ns
INF 2021-10-28 22:43:23.291+02:00 Slot end                                   topics="beacnde" slot=2385815 nextActionWait=n/a nextAttestationSlot=-1 nextProposalSlot=-1 head=eacd2dae:2361096
```
arnetheduck added a commit that referenced this issue Oct 30, 2021
Color support for released binaries!

* add --log-stdout option to control logging to stdout (colors, json)
* detect tty:s vs redirected logs and log accordingly
* add option to disable log colors at runtime
* simplify several "common" logs, showing the most important information
earlier and more clearly
* remove line numbers / file information / tid - these take up space and
are of little use to end users
  * still enabled in debug builds and tools
* remove `testnet_servers_image` compile-time option
* server images, released binaries and compile-from-source now offer
the same behaviour and features
* fixes #2326
* fixes #1794
* fixes #2685
* reshuffle some beacon node init code
* remove instanteneous block speed from sync message, keeping only
average

before:

```
INF 2021-10-28 16:45:59.000+02:00 Slot start
topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:884
lastSlot=2384027 wallSlot=2384028 delay=461us84ns peers=0
head=75a10ee5:3348 headEpoch=104 finalized=cd6804ba:3264
finalizedEpoch=102 sync="wwwwwwwwww:0:0.0000:0.0000:00h00m (3348)"
INF 2021-10-28 16:45:59.046+02:00 Slot end
topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:821 slot=2384028
nextSlot=2384029 head=75a10ee5:3348 headEpoch=104
finalizedHead=cd6804ba:3264 finalizedEpoch=102 nextAttestationSlot=-1
nextProposalSlot=-1 nextActionWait=n/a
```

after:

```
INF 2021-10-28 22:43:23.033+02:00 Slot start
topics="beacnde" slot=2385815 epoch=74556
sync="DDPDDPUDDD:10:5.2258:01h19m (2361088)" peers=37
head=eacd2dae:2361096 finalized=73782:a4751487 delay=33ms687us715ns
INF 2021-10-28 22:43:23.291+02:00 Slot end
topics="beacnde" slot=2385815 nextActionWait=n/a nextAttestationSlot=-1
nextProposalSlot=-1 head=eacd2dae:2361096
```
arnetheduck added a commit that referenced this issue Nov 1, 2021
Color support for released binaries!

* startup scripts no longer log to file by default - this only affects
source builds - released binaries don't support file logging
* add --log-stdout option to control logging to stdout (colors, json)
* detect tty:s vs redirected logs and log accordingly
* add option to disable log colors at runtime
* simplify several "common" logs, showing the most important information
earlier and more clearly
* remove line numbers / file information / tid - these take up space and
are of little use to end users
  * still enabled in debug builds and tools
* remove `testnet_servers_image` compile-time option
* server images, released binaries and compile-from-source now offer
the same behaviour and features
* fixes #2326
* fixes #1794
* remove instanteneous block speed from sync message, keeping only
average

before:

```
INF 2021-10-28 16:45:59.000+02:00 Slot start
topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:884
lastSlot=2384027 wallSlot=2384028 delay=461us84ns peers=0
head=75a10ee5:3348 headEpoch=104 finalized=cd6804ba:3264
finalizedEpoch=102 sync="wwwwwwwwww:0:0.0000:0.0000:00h00m (3348)"
INF 2021-10-28 16:45:59.046+02:00 Slot end
topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:821 slot=2384028
nextSlot=2384029 head=75a10ee5:3348 headEpoch=104
finalizedHead=cd6804ba:3264 finalizedEpoch=102 nextAttestationSlot=-1
nextProposalSlot=-1 nextActionWait=n/a
```

after:

```
INF 2021-10-28 22:43:23.033+02:00 Slot start
topics="beacnde" slot=2385815 epoch=74556
sync="DDPDDPUDDD:10:5.2258:01h19m (2361088)" peers=37
head=eacd2dae:2361096 finalized=73782:a4751487 delay=33ms687us715ns
INF 2021-10-28 22:43:23.291+02:00 Slot end
topics="beacnde" slot=2385815 nextActionWait=n/a nextAttestationSlot=-1
nextProposalSlot=-1 head=eacd2dae:2361096
```
arnetheduck added a commit that referenced this issue Nov 1, 2021
Color support for released binaries!

* startup scripts no longer log to file by default - this only affects
source builds - released binaries don't support file logging
* add --log-stdout option to control logging to stdout (colors, json)
* detect tty:s vs redirected logs and log accordingly
* add option to disable log colors at runtime
* simplify several "common" logs, showing the most important information
earlier and more clearly
* remove line numbers / file information / tid - these take up space and
are of little use to end users
  * still enabled in debug builds and tools
* remove `testnet_servers_image` compile-time option
* server images, released binaries and compile-from-source now offer
the same behaviour and features
* fixes #2326
* fixes #1794
* remove instanteneous block speed from sync message, keeping only
average

before:

```
INF 2021-10-28 16:45:59.000+02:00 Slot start                                 topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:884 lastSlot=2384027 wallSlot=2384028 delay=461us84ns peers=0 head=75a10ee5:3348 headEpoch=104 finalized=cd6804ba:3264 finalizedEpoch=102 sync="wwwwwwwwww:0:0.0000:0.0000:00h00m (3348)"
INF 2021-10-28 16:45:59.046+02:00 Slot end                                   topics="beacnde" tid=386429 file=nimbus_beacon_node.nim:821 slot=2384028 nextSlot=2384029 head=75a10ee5:3348 headEpoch=104 finalizedHead=cd6804ba:3264 finalizedEpoch=102 nextAttestationSlot=-1 nextProposalSlot=-1 nextActionWait=n/a
```

after:

```
INF 2021-10-28 22:43:23.033+02:00 Slot start                                 topics="beacnde" slot=2385815 epoch=74556 sync="DDPDDPUDDD:10:5.2258:01h19m (2361088)" peers=37 head=eacd2dae:2361096 finalized=73782:a4751487 delay=33ms687us715ns
INF 2021-10-28 22:43:23.291+02:00 Slot end                                   topics="beacnde" slot=2385815 nextActionWait=n/a nextAttestationSlot=-1 nextProposalSlot=-1 head=eacd2dae:2361096
```
@zah zah closed this as completed in 233d756 Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants