/* only one instance, only one syslog, so globals should be ok */
static PyObject *S_ident_o = NULL; /* identifier, held by openlog() */
+static char S_log_open = 0;
static PyObject *
*/
openlog(S_ident_o ? PyString_AsString(S_ident_o) : NULL, logopt, facility);
+ S_log_open = 1;
Py_INCREF(Py_None);
return Py_None;
return NULL;
}
- /* call openlog if no current identifier */
- if (!S_ident_o) {
+ /* if log is not opened, open it now */
+ if (!S_log_open) {
PyObject *openargs;
/* Continue even if PyTuple_New fails, because openlog(3) is optional.
static PyObject *
syslog_closelog(PyObject *self, PyObject *unused)
{
- closelog();
- Py_XDECREF(S_ident_o);
- S_ident_o = NULL;
+ if (S_log_open) {
+ closelog();
+ Py_XDECREF(S_ident_o);
+ S_ident_o = NULL;
+ S_log_open = 0;
+ }
Py_INCREF(Py_None);
return Py_None;
}