What is Nostr?
Space Hobo /
npub1day…wuks
2023-12-11 22:19:48
in reply to nevent1q…jxa7

Space Hobo on Nostr: npub14wsy6…rdrhu npub1a3hfc…9m44m I discovered a while ago that I could do this ...

npub14wsy68pyduanfdrqrrrr7j62qezr0nemfvsprcvkyk7xz49gyrxs0rdrhu (npub14ws…drhu) npub1a3hfcvq3wa9zggsur737r9j095kh76rqy46we58jzu345xl4n3eqz9m44m (npub1a3h…m44m) I discovered a while ago that I could do this in #Python scripts:

```
if args.syslog or not sys.stdout.isatty():
handler = logging.handlers.SysLogHandler(
address='/dev/log',
facility=logging.handlers.SysLogHandler.LOG_DAEMON)
formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')
handler.setFormatter(formatter)
mylogger.addHandler(handler)
else: # use the basic config when on terminal
debugLevel = logging.WARNING - (args.verbose * 10)
logging.basicConfig(level=max(debugLevel, 0))
```

This meant I not only got verbosity for free, but all those logged messages on `stderr` would automatically go to syslog if this wasn't run from a terminal. All of a sudden my cron spam dropped and I could use existing tools to analyse problems in the logs.

You could probably also catch `-q` as a quiet option and add that to the log level calculations at the end without more verbosity.
Author Public Key
npub1dayn4yhqczej88j7023hwzrl6e37v0djuxg3cg455l3udqv6rctqllwuks