rss2email / rss2email

Forward RSS feeds to your email address, community maintained
https://pypi.org/project/rss2email/
GNU General Public License v2.0
366 stars 61 forks source link

Error messages aren't idiomatic Unix #143

Open RalphCorderoy opened 4 years ago

RalphCorderoy commented 4 years ago

Arch Linux's rss2email AUR 3.12.1-1 reports errors in a very non-Unix style.

$ r2e list
2020-09-12 12:30:25,981 [ERROR] extra configuration key: foo
$

I'd expect

r2e: error: extra configuration key: foo
Ekleog commented 4 years ago

Makes sense, we can probably improve on the error message :) I think the shouting may be non-trivial to fix, that said, as we are just using whatever way the logging module has of giving the log level, and I'm not sure it's that useful to add r2e: in front of the log line as it, in the same way as the timestamp, should be added by the thing that runs r2e and knows best what identifier to use; but I'm with you we probably should at least remove the timestamps from the log messages as they don't bring much actual value :)

RalphCorderoy commented 4 years ago

I disagree that the runner of r2e(1) should prefix r2e's stderr output with r2e:. No Unix program assumes that as it means every run of a command in a shell script would have to

$ r2e list 2> >(sed 's/^/r2e: /' >&2) | wc -c
r2e: 2020-09-14 08:51:24,174 [ERROR] extra configuration key: foo
0
$ 

except isn't quite equivalent because it delays stderr by buffering it through sed(1) so the order of the union of stdout and stderr lines isn't preserved.

Here's how it should work using ls(1) for demonstration. This behaviour is probably mandated by POSIX.

$ ls /usr/bin/r2e /missing | nl
ls: cannot access '/missing': No such file or directory
     1  /usr/bin/r2e
$ cp /usr/bin/ls myls
$ ./myls /usr/bin/r2e /missing | nl
myls: cannot access '/missing': No such file or directory
     1  /usr/bin/r2e
$
Ekleog commented 4 years ago

While I see your point, I do not see any reason to prefix things with argv[0] that'd be worth adding that logic, and following POSIX blindly seems pointless to me — what's important is UX, and UX is, as you mentioned, hurt by the timestamps that are added for no real reason.

(as a side-rant, I believe a significant amount of things in POSIX are really ill-thought for today's computers, a prime example of it being signals, so “but POSIX” isn't really an argument that's going to hold here)

auouymous commented 4 years ago

Not knowing which program generated an error is poor UX. You know which program failed when run from command line, but running from a GUI (dock) can cause errors to be written to an xinit terminal or log (good luck figuring out which program it was). I run r2e from cron and the command is in the subject but it would be nice if argv[0] prefixed the error in email body.

RalphCorderoy commented 4 years ago

Anyone who has done Unix scripting has faced tracking down what program in a large tree of forks and execs produced an odd bit of output. POSIX standardised what is long-established custom dating all the way back to when Unix was used by a few in 1127 at Bell Labs. Prefixing a line of stderr output with basename $0 is not an ill-thought-out corner of POSIX.

Ekleog commented 4 years ago

I actually haven't faced this problem for a few years now, both systemd and cron already prefix with the executable name, and I can't see people reasonably trying to run rss2email from a dock or similar (they'd probably just use GUI RSS viewers, which are much more user-friendly for this use case).

If someone has a practical complaint about this being an issue for them then why not, but for now it just sounds like “it'd be better if” that has no concrete use case identified yet. I want for proof the fact that the only other thing on my computer that actually has the same running model as rss2email on my computer, ie. freshclam, also does not prefix its lines with freshclam — nor do any of the long-running services, though this is less of a point because they're even less likely to be run outside a service manager.

RalphCorderoy commented 4 years ago

I run rss2email(1) from a script started by me at a shell prompt, not with cron or systemd. The script runs lots of other scripts and commands.