jesec / rtorrent

stable, high-performance and low resource consumption BitTorrent client
GNU General Public License v2.0
192 stars 38 forks source link

Log to stdout #40

Open peloyeje opened 2 years ago

peloyeje commented 2 years ago

Hello,

I'm currently trying to output logs to stdout in order to take advantage of s6 log handling system, here what I did so far:

...
log.open_file = "main", (cat, "/dev/stdout")

# Based on levels defined here: https://github.com/jesec/libtorrent/blob/master/include/torrent/utils/log.h
log.add_output = "dht_info", "main"
log.add_output = "peer_info", "main"
...

After granting the user running rtorrent the rights to write to /dev/pts/0, logging correctly appears in stdout:

rTorrent: started, 0 torrents loaded
1653143350 N rtorrent scgi: Starting thread.
1653143350 N rtorrent main: Starting thread.

But an error msg pops before any output: Error in option file: /config/rtorrent/rtorrent.d/05-log.rc:2: Could not open log file '/dev/stdout'.

I was wondering if that's a good way to go - my c++ fu is pretty basic and I don't really know the semantics/primitives to write to stdout in this language haha - or whether stdout support requires some adjustments and should be a feature request.

For additional context, with this setup, s6-overlay logging capture feature is not working as expected: only the aforementioned log line is captured endlessly. AFAIU this feature works by creating in/out fd for each program and passing them around (hope I got it right), could this be related to the fact that I specified /dev/stdout explicitely?

Thanks for the help! Happy to provide any info