[Tutor] Please help disentangle my program logic
Cameron Simpson
cs at cskk.id.au
Sun Jan 5 18:19:40 EST 2020
On 05Jan2020 19:37, Robert Alexander <gogonegro at gmail.com> wrote:
>My program currently handles an “exception” and exits if a prerequisite
>external program is not found. So that would go to STDOUT/ERR and the logs
>proper to a log via the logging module.
The default logger sends to stderr, BTW. So for simple things I just log
errors etc via the default logging calls and they come out on stderr as
normal for a UNIXy command line.
Another nice thing about the logging module is that the format facility
lets you configure it to do boilerplate like the timestamp or log level
label, for example:
'%(asctime)s %(levelname)s %(message)s'
However, your setup line:
nohup python -u speedtest.py >> adsl.log &
expects stuff to come from the standard output. You'd want:
nohup python -u speedtest.py >> adsl.log 2>&1 &
to use the default logging arrangement.
On the subject of starting long running daemons, personally I kick a lot
of daemony things off in tmux (like a more modern screen) instead of
using nohup. That way I've got a nicely named session I can reconnect
to, and I can just interrupt it and restart it differently or whatever.
>> PS Etiquette question please: Is it better to reply to both the
>> sender and the list or the list only?
I tend to reply to the list and the sender by default, with the
Reply-To: set to the list address. But just-to-the-list is also normal,
and arguably more polite.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list