How to get the current set LOG_MASK in Python's syslog module?

Richard Moseley richardmoseley4 at gmail.com
Thu Sep 22 09:44:38 EDT 2022


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.

On Thu, 22 Sep 2022, 14:32 , <c.buhtz at posteo.jp> wrote:

> X-Post: https://stackoverflow.com/q/73814924/4865723
>
> Hello,
>
> I'm aware that there is a `logging` package that is more _modern_ then
> [`syslog`](https://docs.python.org/3/library/syslog.html). But I have
> old code here to deal with that does use `syslog`. So that question is
> specific to `syslog` and not to `logging`.
>
> I would like to get the current `LOG_MASK`, which is kind of a logging
> level. According to the docu it seems that `syslog` doesn't have a
> mechanism for that.
>
> Does someone has an idea?
>
> The docu also tells me that `syslog` does let pass all messages by
> default.
> My point is I do manipulate via `syslog.setlogmask()` the current log
> leve. At the end I would like to set it back to its previous value.
>
> Kind
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list