-u syslog doesn't work on macOS
General informations
- system/distribution (with version): macOS 10.13.4
- offlineimap version (
offlineimap -V): 7.2.0 - Python version: 2.7.15
- server name or domain: smtp.gmail.com
- CLI options: -u syslog
Configuration file offlineimaprc
[general]
accounts = Personal
maxsyncaccounts = 1
ui = Basic
[mbnames]
enabled = yes
filename = ~/Mail/muttrc.mailboxes
header = "mailboxes "
peritem = "+%(accountname)s/%(foldername)s"
sep = " "
footer = "\n"
[Account Personal]
localrepository = LocalPersonal
remoterepository = RemotePersonal
autorefresh = 5
quick = 5
[Repository LocalPersonal]
type = GmailMaildir
localfolders = ~/Mail/Personal
[Repository RemotePersonal]
type = Gmail
remoteuser = [email protected]
remotepassfile = ~/.offlineimap-personal
sslcacertfile = /usr/local/etc/openssl/cert.pem
maxconnections = 2
Logs, error
Traceback (most recent call last):
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap.py", line 22, in <module>
oi.run()
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap/init.py", line 89, in run
options, args = self.__parse_cmd_options()
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap/init.py", line 269, in __parse_cmd_options
self.ui = UI_LIST[ui_type.lower()](config)
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap/ui/Noninteractive.py", line 37, in __init__
return super(Syslog, self).__init__(config, loglevel)
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap/ui/UIBase.py", line 75, in __init__
self._log_con_handler = self.setup_consolehandler()
File "/usr/local/Cellar/offlineimap/7.2.0/libexec/offlineimap/ui/Noninteractive.py", line 41, in setup_consolehandler
ch = logging.handlers.SysLogHandler('/dev/log')
File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/handlers.py", line 761, in __init__
self._connect_unixsocket(address)
File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/handlers.py", line 804, in _connect_unixsocket
self.socket.connect(address)
File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory
Steps to reproduce the error
- Just try to use
-u syslogon macOS
macOS doesn't provide /dev/log. I see a socket under /var/log/syslog and maybe this is the same expected by offlinimap in this case.
We should use the python syslog module here, for compatibility on all Linux MacOS, every OS:
import syslog
def main():
syslog.syslog(syslog.LOG_INFO, "Everything is working OK.")
syslog.syslog(syslog.LOG_ERR, "This is logged at the error level")
if __name__ == "__main__":
main()
I recently switched over to mac and ran into this same problem. Maybe my reading of the docs is a bit naive, but from the section on the SysLogHandler link class, it looks the current offlineimap handler has a hard-coded path to the syslog socket (on Linux) as opposed to being based on a network address/port. The current hard-coded path is for Linux syslog daemons, which I think is why it fails on mac.
My simple PR #623 just put a runtime check into setup_sysloghandler to set the correct socket path based on the system, but maybe there's a better way to handle this?
Patch applied.