Exclude cfg.Stderr if only Stdout is provided in env var
Introduction 👋
If I want to change the logging output from Stderr to Stdout, the os env GOLOG_OUTPUT should be changed to stdout
Still, after setting env to only stdout - I still see that the same log is duplicated in both pipelines(StdErr, Stdout)
This behaviour was found during testing in testground and the testable application is using ipfs/go-log/v2 logger
-
ERRORlogs show the same asOTHER
Example of testground's log
Aug 22 11:38:39.023690 INFO 65.2779s ERROR << instance[002] (9c984e) >>
Aug 22 11:38:39.023713 INFO 65.2779s ERROR << instance[002] (9c984e) >> /_____/ /_____/ /_____/ /_____/ /_____/
Aug 22 11:38:39.023753 INFO 65.2780s ERROR << instance[002] (9c984e) >>
Aug 22 11:38:39.023794 INFO 65.2780s ERROR << instance[002] (9c984e) >> Started celestia DA node
Aug 22 11:38:39.023826 INFO 65.2780s ERROR << instance[002] (9c984e) >> node type: bridge
Aug 22 11:38:39.023868 INFO 65.2781s ERROR << instance[002] (9c984e) >> network: private
Aug 22 11:38:39.023901 INFO 65.2781s ERROR << instance[002] (9c984e) >>
Aug 22 11:38:39.023954 INFO 65.2782s ERROR << instance[002] (9c984e) >> /_____/ /_____/ /_____/ /_____/ /_____/
Aug 22 11:38:39.023989 INFO 65.2782s OTHER << instance[002] (9c984e) >> 2022-08-22T11:38:39.023Z INFO node node/node.go:104
Aug 22 11:38:39.024010 INFO 65.2782s ERROR << instance[002] (9c984e) >>
Aug 22 11:38:39.024025 INFO 65.2782s OTHER << instance[002] (9c984e) >>
Aug 22 11:38:39.024070 INFO 65.2783s OTHER << instance[002] (9c984e) >> /_____/ /_____/ /_____/ /_____/ /_____/
Aug 22 11:38:39.024100 INFO 65.2783s OTHER << instance[002] (9c984e) >>
Aug 22 11:38:39.024126 INFO 65.2783s OTHER << instance[002] (9c984e) >> Started celestia DA node
Aug 22 11:38:39.024148 INFO 65.2784s OTHER << instance[002] (9c984e) >> node type: bridge
Aug 22 11:38:39.024168 INFO 65.2784s OTHER << instance[002] (9c984e) >> network: private
Aug 22 11:38:39.024206 INFO 65.2784s OTHER << instance[002] (9c984e) >>
Aug 22 11:38:39.024227 INFO 65.2784s OTHER << instance[002] (9c984e) >> /_____/ /_____/ /_____/ /_____/ /_____/
Aug 22 11:38:39.024249 INFO 65.2785s OTHER << instance[002] (9c984e) >>
Solutions 🧐
There are 2 approaches that I've found for myself:
- If we set the env
GOLOG_FILEto/dev/nullandGOLOG_OUTPUT = stdout, then Stderr (hence,ERRORin testground) won't appear anymore - If the user is explicitly setting the env to only stdout, the why should we also leave Stderr flag to true? There is already a possibility to add multiple options in the env, so I propose the selection to be more strict. Example: https://github.com/ipfs/go-log/pull/135
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:
- "Priority" labels will show how urgent this is for the team.
- "Status" labels will show if this is ready to be worked on, blocked, or in progress.
- "Need" labels will indicate if additional input or analysis is required.
Finally, remember to use https://discuss.ipfs.io if you just need general support.