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

Normal tarsnapper output goes to stderr instead of stdout #26

Open
Haprog opened this issue Jun 10, 2015 · 3 comments
Open

Normal tarsnapper output goes to stderr instead of stdout #26

Haprog opened this issue Jun 10, 2015 · 3 comments

Comments

@Haprog
Copy link

Haprog commented Jun 10, 2015

When I run

tarsnapper -c /usr/local/etc/tarsnapper.conf make

I get output like

Creating backup mail: mybackupjob-20150610-092951
3 backups are matching
0 of those can be deleted

I would like to suppress normal output like this (which should be stdout) when I run tarsnapper using cron so that I only get email from cron when there is an error (something output to stderr)

So I tried:

tarsnapper -c /usr/local/etc/tarsnapper.conf make >/dev/null

But I still get the same output! I figured only when I redirect using 2>/dev/null I get rid of this output so tarsnapper seems to output this normal output to stderr which is a bug in my opinion. Only errors should be output to stderr and everything else to stdout.

I'm running on Ubuntu 15.04 using tarsnapper installed with easy_install.

@miracle2k
Copy link
Owner

The Python log library is used, and this is it's default behaviour, because I believe the standard assumption is indeed that messages (error or otherwise) go to stderr, whereas stdout is for data.

This way, when you do convert file.png > out.png, you get log messages on the console and the data in the file.

Of course, tarsnapper does not have any actual "data".

Still, I would lean towards a "log level" option instead, where for running in cron you could simply disable messages that aren't errors.

@Haprog
Copy link
Author

Haprog commented Jun 10, 2015

Well I think either

  1. the non-error output should go to stdout and errors to stderr (then it would be easy to redirect both separately wherever you want) or
  2. we need some options/parameters that allow to disable non-error output only and possibly an additional option that allows appending all messages (non-errors and errors) to a logfile while outputting only errors.

I think it would just add unnecessary complexity to implement number 2 (more parameters), because stdout and stderr are already easy to work with and why not use stdout for non-error messages when it's not used for anything else?

@miracle2k
Copy link
Owner

A --quiet flag is pretty simple to do, and I have a preference for it, since it is pretty standard.

Having said that, maybe it deserves reconsidering what "standard" output is vs what is a log message. Anyway, I don't want to overthink this. If you want to submit a pull request I'm fine with either.

See also: http://stackoverflow.com/questions/2302315/how-can-info-and-debug-logging-message-be-sent-to-stdout-and-higher-level-messag

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

2 participants