Rsudp - logging to syslog?

i see rsudp logs into hard-coded location under /tmp.
note that debian how mounts /tmp on ramfs, so on reboot the whole log is lost.
has anyone rewritten rsudp to use syslog (thence journald)?
it appears to use python logging somewhat but hardcoded to stream to file

As of the latest version, no, the default location remains /tmp.

Until a new update comes out, you can directly change the hardcoding once RSUDP has been installed (probably the easiest solution), or enable a service that would mirror the log files into syslog/journald, or a different service that would symlink the log files in another directory of your choosing.

i thought that would be the (quite reasonable) response, and i just finished inserting some code to divert the LOG data (the printM, printW, printE etc functions) to syslog.
looking in rsudp/__init__.py, after line 142 (with line 142 and original line 143 shown for context), i inserted

▸···LOG.addHandler(f)                            
                    
▸···#GE added start 
▸···try:            
▸···▸···from logging.handlers import SysLogHandler      
▸···▸···LOG.addHandler(SysLogHandler(address="/dev/log")) 
▸···▸···LOG.removeHandler(f)                     
▸···▸···printM(f"Using SysLogHandler instead of FileHandler", sender='Init')
▸···except Exception as e:                       
▸···▸···printM(f"No SysLogHandler: {e}", sender='Init') 
▸···#GE added finish
                    
▸···printM('Logging initialized successfully.', sender='Init')

i have been a bit lazy in being non-selective on the exceptions captured…
the nett result is, if syslog available, it displaces the file log.

in a separate forum topic, i showed the systemd unit file i am using to control rsudp (i.e. # systemctl start rsudp and # systemctl stop rsudp). this means i use # journalctl -u rsudp -f to track the log output.
note that the app does some print()s, not to log, and they still go to /tmp/rsudp/rsudp.log.

1 Like

The important thing is that it is now working as you intended.

I’ve added a reminder for the software team, so that they can explore making the log folder as a user-selected variable, that doesn’t go to /tmp by default. Giving more configuration freedom, in the end.

Thank you for all the feedback you provided in these days!

i would ask that they use logging.config module, and provide in settings a default of streaming to a text file, maybe something like

"logging": {      
    "version": 1, 
    "disable_existing_loggers": false,
    "root": {     
        "level": "INFO",              
        "handlers": [ "file" ]        
    },            
    "handlers": { 
        "file": { 
            "class": "logging.FileHandler",
            "formatter": "simple",    
            "filename": "app.log",    
            "mode": "w"               
        }         
    },            
    "formatters": {                   
        "simple": {                   
            "format": "(levelname)-8s %(message)s"
        }         
    }             
}

this can be changed easily to point to another file location, or in my case replace handler with a SyslogHandler. note - you can add as many handlers as wanted, the log messages get copied to all of them

2 Likes