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.
Published at
2023-12-11 22:19:48Event JSON
{
"id": "86d73e57ce7382f05d0c9817b0a67815458c7b982ea645fcc47e7f4d2a947e5c",
"pubkey": "6f493a92e0c0b3239e5e7aa377087fd663e63db2e1911c22b4a7e3c6819a1e16",
"created_at": 1702333188,
"kind": 1,
"tags": [
[
"p",
"aba04d1c246f3b34b46018c63f4b4a064437cf3b4b2011e19625bc6154a820cd",
"wss://relay.mostr.pub"
],
[
"p",
"ec6e9c3011774a24221c1fa3e1964f2d2d7f68602574ecd0f217235a1bf59c72",
"wss://relay.mostr.pub"
],
[
"p",
"1c916e3126795bb0d5ae867e590cca6f61e7359762647d2847427b23b541e04b",
"wss://relay.mostr.pub"
],
[
"p",
"579852afc54f2f4b992d5c48441d63f6545c530a7371764b6e67325d585ea6a1",
"wss://relay.mostr.pub"
],
[
"e",
"ed8b0cf3eea0ced1cc1ddeab1c6844c8c2af039cc3c5fcde126d38c98512f426",
"wss://relay.mostr.pub",
"reply"
],
[
"t",
"python"
],
[
"proxy",
"https://teh.entar.net/users/spacehobo/statuses/111564107826748048",
"activitypub"
]
],
"content": "nostr:npub14wsy68pyduanfdrqrrrr7j62qezr0nemfvsprcvkyk7xz49gyrxs0rdrhu nostr:npub1a3hfcvq3wa9zggsur737r9j095kh76rqy46we58jzu345xl4n3eqz9m44m I discovered a while ago that I could do this in #Python scripts:\n\n```\n if args.syslog or not sys.stdout.isatty():\n handler = logging.handlers.SysLogHandler(\n address='/dev/log',\n facility=logging.handlers.SysLogHandler.LOG_DAEMON)\n formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s')\n handler.setFormatter(formatter)\n mylogger.addHandler(handler)\n else: # use the basic config when on terminal\n debugLevel = logging.WARNING - (args.verbose * 10)\n logging.basicConfig(level=max(debugLevel, 0))\n```\n\nThis 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.\n\nYou could probably also catch `-q` as a quiet option and add that to the log level calculations at the end without more verbosity.",
"sig": "4958fcbde93c212f49458911996aca4e208c27a44cebd96457175824bba548117a707b283cf97a521fda058016c62bc42394e045cbbc9e8225e300d709fd2ae9"
}