[GH-ISSUE #690] All messages are sent to stdout, even errors, which should be in stderr. #393

Closed
opened 2026-02-27 19:30:22 +03:00 by kerem · 4 comments
Owner

Originally created by @ghost on GitHub (Apr 11, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/690

Librespot echoes everything into stdout. This could be improved by properly echoing all INFO messages to stdout and all WARN and ERROR messages to stderr.

Currently, when I start librespot with:

# ./librespot > /dev/null

I would expect all info messages redirected to /dev/null, but still see any possible warnings or errors. However, this is not the case.

This also breaks when using systemd and specifying:

StandardOutput=append:/var/log/librespot.stdout.log
StandardError=append:/var/log/librespot.stderr.log

With this configuration, all messages are in the librespot.stdout.log file.

Originally created by @ghost on GitHub (Apr 11, 2021). Original GitHub issue: https://github.com/librespot-org/librespot/issues/690 Librespot echoes everything into `stdout`. This could be improved by properly echoing all `INFO` messages to stdout and all `WARN` and `ERROR` messages to stderr. Currently, when I start librespot with: ``` # ./librespot > /dev/null ``` I would expect all info messages redirected to `/dev/null`, but still see any possible warnings or errors. However, this is not the case. This also breaks when using `systemd` and specifying: ``` StandardOutput=append:/var/log/librespot.stdout.log StandardError=append:/var/log/librespot.stderr.log ``` With this configuration, all messages are in the `librespot.stdout.log` file.
kerem closed this issue 2026-02-27 19:30:22 +03:00
Author
Owner

@roderickvd commented on GitHub (Apr 12, 2021):

I agree but this is not supported by the env_logger crate. It would require moving to some other crate or writing an own logger implementation.

<!-- gh-comment-id:817652643 --> @roderickvd commented on GitHub (Apr 12, 2021): I agree but this is not supported by the `env_logger` crate. It would require moving to some other crate or writing an own logger implementation.
Author
Owner

@Johannesd3 commented on GitHub (Apr 12, 2021):

First of all: AFAIK all log messages are printed to stderr, not stdout. Which of us is wrong?

I do not agree: stderr is in a way a misleading name, because it's not only intended for errors, but for all kind of status messages. E.g. curl will print the download progress to stderr (if stdout is redirected). Or bash will show the $ on stderr.

stdout is often used for that kind of output that is the purpose of the program, e.g. the list of files in ls, the downloaded file in curl.

And as a matter of fact, librespot uses already stdout for another purpose: If the "pipe" backend is selected, the audio data will be passed to stdout. Considering this, your idea doesn't make so much sense anymore.

If you just want to see errors and warning, use the RUST_LOG environment variable. If you want to log all messages but see only errors, use grep to filter the messages. Another advantage: If you use a single file, the order of messages will be preserved.

<!-- gh-comment-id:817935998 --> @Johannesd3 commented on GitHub (Apr 12, 2021): First of all: AFAIK all log messages are printed to `stderr`, not `stdout`. Which of us is wrong? I do not agree: `stderr` is in a way a misleading name, because it's not only intended for errors, but for all kind of status messages. E.g. curl will print the download progress to `stderr` (if `stdout` is redirected). Or `bash` will show the `$ ` on `stderr`. `stdout` is often used for that kind of output that is the purpose of the program, e.g. the list of files in `ls`, the downloaded file in `curl`. And as a matter of fact, librespot uses already `stdout` for another purpose: If the "pipe" backend is selected, the audio data will be passed to `stdout`. Considering this, your idea doesn't make so much sense anymore. If you just want to see errors and warning, use the `RUST_LOG` environment variable. If you want to log all messages but see only errors, use `grep` to filter the messages. Another advantage: If you use a single file, the order of messages will be preserved.
Author
Owner

@roderickvd commented on GitHub (Apr 12, 2021):

I stand corrected, you are right and was mistaken with logging levels. Which should work fine.

@coderootme you should use 2>/dev/null syntax to redirect stderr

<!-- gh-comment-id:817966429 --> @roderickvd commented on GitHub (Apr 12, 2021): I stand corrected, you are right and was mistaken with logging levels. Which should work fine. @coderootme you should use `2>/dev/null` syntax to redirect `stderr`
Author
Owner

@ghost commented on GitHub (Apr 12, 2021):

Yes, guys, I am sorry. Everything goes to stderr. My point still stands, however, but it seems like you don't agree with that idea, so I will close it here.

<!-- gh-comment-id:818051230 --> @ghost commented on GitHub (Apr 12, 2021): Yes, guys, I am sorry. Everything goes to stderr. My point still stands, however, but it seems like you don't agree with that idea, so I will close it here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#393
No description provided.