On Thu, 22 Sept 2022 at 23:46, Richard Moseley
<richardmosel...@gmail.com> wrote:
>
> According to documentation syslog.setlogmask returns the current mask so
> save the value to reset later on.
>
> Oldval = syslog.setlogmask(newmask)
>
> This sets oldval to original mask.

This on its own suggests an odd technique that should work but won't be great:

oldval = syslog.setlogmask(1234)
syslog.setlogmask(oldval)

But the Python function just passes the value straight to the
underlying system call, and thus treats zero specially:

"""
The setlogmask() function sets this logmask for the calling
process, and returns the previous mask.  If the mask argument is
0, the current logmask is not modified.
"""

So you should be able to do:

current_mask = syslog.setlogmask(0)

The Python docs do say to refer to the man pages, but IMO it would be
worth mentioning this feature specifically in the docs.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to