This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: syslog.syslog() does not return error when unable to send the log
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Cyril Bouthors, martin.panter, r.david.murray
Priority: normal Keywords:

Created on 2015-08-12 17:01 by Cyril Bouthors, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg248462 - (view) Author: Cyril Bouthors (Cyril Bouthors) Date: 2015-08-12 17:01
Hi guys,

syslog.syslog() does not report any error when it fails to send messages to syslog. To reproduce:

Stop sysglog:

sudo /etc/init.d/rsyslog stop

Run than Python code:

import syslog
syslog.syslog('test')

It does not fail.

Strace shows that's it's been unable to send the message to syslog:

connect(3, {sa_family=AF_LOCAL, sun_path="/dev/log"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fc899e4a8d0}, {0x55e6b0, [], SA_RESTORER, 0x7fc899e4a8d0}, 8) = 0
brk(0x20ed000)                          = 0x20ed000
exit_group(0)                           = ?
+++ exited with 0 +++

I've tested all those versions:

echo -e "import syslog\nsyslog.syslog('test')\n" | python3.5
echo -e "import syslog\nsyslog.syslog('test')\n" | python3.4
echo -e "import syslog\nsyslog.syslog('test')\n" | python3.3
echo -e "import syslog\nsyslog.syslog('test')\n" | python3.2
echo -e "import syslog\nsyslog.syslog('test')\n" | python2.7
echo -e "import syslog\nsyslog.syslog('test')\n" | python2.6

Can we please get syslog() to report errors?

Thanks.
msg248465 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-12 17:11
Hmm.  Normally the way errors are reported in python is via exception.  personally I would not want syslog raising an exception if it couldn't deliver the message.

I suppose we could have it return a status code.  That would be a new feature, though.
msg249099 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-08-25 02:46
I’ve never used syslog() in Python, but I thought I should point out that the standard Posix API does not do any error reporting either. See <http://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html>: “The . . . functions shall not return a value. / No errors are defined.”
msg249116 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-08-25 12:37
Ah, in that case there aren't any errors for us to return, so this is moot.
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 69038
2015-08-25 12:37:35r.david.murraysetstatus: open -> closed
resolution: not a bug
messages: + msg249116

stage: resolved
2015-08-25 02:46:54martin.pantersetnosy: + martin.panter
messages: + msg249099
2015-08-12 17:11:44r.david.murraysetversions: + Python 3.6, - Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5
nosy: + r.david.murray

messages: + msg248465

type: behavior -> enhancement
2015-08-12 17:01:25Cyril Bouthorscreate