Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 2 | Copyright 1994 by Lance Ellinghouse, |
| 3 | Cathedral City, California Republic, United States of America. |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 11 | supporting documentation, and that the name of Lance Ellinghouse |
| 12 | not be used in advertising or publicity pertaining to distribution |
| 13 | of the software without specific, written prior permission. |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 14 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 15 | LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 17 | FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL, |
| 18 | INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
| 19 | FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
| 20 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
| 21 | WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 22 | |
| 23 | ******************************************************************/ |
| 24 | |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 25 | /****************************************************************** |
| 26 | |
| 27 | Revision history: |
| 28 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 29 | 2010/04/20 (Sean Reifschneider) |
| 30 | - Use basename(sys.argv[0]) for the default "ident". |
| 31 | - Arguments to openlog() are now keyword args and are all optional. |
| 32 | - syslog() calls openlog() if it hasn't already been called. |
| 33 | |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 34 | 1998/04/28 (Sean Reifschneider) |
| 35 | - When facility not specified to syslog() method, use default from openlog() |
| 36 | (This is how it was claimed to work in the documentation) |
| 37 | - Potential resource leak of o_ident, now cleaned up in closelog() |
| 38 | - Minor comment accuracy fix. |
| 39 | |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 40 | 95/06/29 (Steve Clift) |
| 41 | - Changed arg parsing to use PyArg_ParseTuple. |
| 42 | - Added PyErr_Clear() call(s) where needed. |
| 43 | - Fix core dumps if user message contains format specifiers. |
Thomas Wouters | 7e47402 | 2000-07-16 12:04:32 +0000 | [diff] [blame] | 44 | - Change openlog arg defaults to match normal syslog behavior. |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 45 | - Plug memory leak in openlog(). |
| 46 | - Fix setlogmask() to return previous mask value. |
| 47 | |
| 48 | ******************************************************************/ |
| 49 | |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 50 | /* syslog module */ |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 51 | |
Guido van Rossum | a597dde | 1995-01-10 20:56:29 +0000 | [diff] [blame] | 52 | #include "Python.h" |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 53 | #include "osdefs.h" |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 54 | |
| 55 | #include <syslog.h> |
| 56 | |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 57 | /* only one instance, only one syslog, so globals should be ok */ |
| 58 | static PyObject *S_ident_o = NULL; /* identifier, held by openlog() */ |
| 59 | |
| 60 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 61 | static PyObject * |
| 62 | syslog_get_argv(void) |
| 63 | { |
| 64 | /* Figure out what to use for as the program "ident" for openlog(). |
| 65 | * This swallows exceptions and continues rather than failing out, |
| 66 | * because the syslog module can still be used because openlog(3) |
| 67 | * is optional. |
| 68 | */ |
| 69 | |
| 70 | Py_ssize_t argv_len; |
| 71 | PyObject *scriptobj; |
| 72 | char *atslash; |
| 73 | PyObject *argv = PySys_GetObject("argv"); |
| 74 | |
| 75 | if (argv == NULL) { |
| 76 | return(NULL); |
| 77 | } |
| 78 | |
| 79 | argv_len = PyList_Size(argv); |
| 80 | if (argv_len == -1) { |
| 81 | PyErr_Clear(); |
| 82 | return(NULL); |
| 83 | } |
| 84 | if (argv_len == 0) { |
| 85 | return(NULL); |
| 86 | } |
| 87 | |
| 88 | scriptobj = PyList_GetItem(argv, 0); |
| 89 | if (!PyString_Check(scriptobj)) { |
| 90 | return(NULL); |
| 91 | } |
| 92 | if (PyString_GET_SIZE(scriptobj) == 0) { |
| 93 | return(NULL); |
| 94 | } |
| 95 | |
| 96 | atslash = strrchr(PyString_AsString(scriptobj), SEP); |
| 97 | if (atslash) { |
| 98 | return(PyString_FromString(atslash + 1)); |
| 99 | } else { |
| 100 | Py_INCREF(scriptobj); |
| 101 | return(scriptobj); |
| 102 | } |
| 103 | |
| 104 | return(NULL); |
| 105 | } |
| 106 | |
| 107 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 108 | static PyObject * |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 109 | syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 110 | { |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 111 | long logopt = 0; |
| 112 | long facility = LOG_USER; |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 113 | PyObject *new_S_ident_o = NULL; |
| 114 | static char *keywords[] = {"ident", "logoption", "facility", 0}; |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 115 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 116 | if (!PyArg_ParseTupleAndKeywords(args, kwds, |
| 117 | "|Sll:openlog", keywords, &new_S_ident_o, &logopt, &facility)) |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 118 | return NULL; |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 119 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 120 | if (new_S_ident_o) { Py_INCREF(new_S_ident_o); } |
| 121 | |
Sean Reifscheider | 04f4347 | 2010-04-23 08:38:24 +0000 | [diff] [blame^] | 122 | /* get sys.argv[0] or NULL if we can't for some reason */ |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 123 | if (!new_S_ident_o) { |
| 124 | new_S_ident_o = syslog_get_argv(); |
| 125 | } |
| 126 | |
Raymond Hettinger | 6f5b741 | 2004-12-16 23:52:04 +0000 | [diff] [blame] | 127 | Py_XDECREF(S_ident_o); |
| 128 | S_ident_o = new_S_ident_o; |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 129 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 130 | /* At this point, S_ident_o should be INCREF()ed. openlog(3) does not |
| 131 | * make a copy, and syslog(3) later uses it. We can't garbagecollect it |
Sean Reifscheider | 04f4347 | 2010-04-23 08:38:24 +0000 | [diff] [blame^] | 132 | * If NULL, just let openlog figure it out (probably using C argv[0]). |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 133 | */ |
| 134 | |
| 135 | openlog(S_ident_o ? PyString_AsString(S_ident_o) : NULL, logopt, facility); |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 136 | |
| 137 | Py_INCREF(Py_None); |
| 138 | return Py_None; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 141 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 142 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 143 | syslog_syslog(PyObject * self, PyObject * args) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 144 | { |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 145 | char *message; |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 146 | int priority = LOG_INFO; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 147 | |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 148 | if (!PyArg_ParseTuple(args, "is;[priority,] message string", |
| 149 | &priority, &message)) { |
| 150 | PyErr_Clear(); |
| 151 | if (!PyArg_ParseTuple(args, "s;[priority,] message string", |
| 152 | &message)) |
| 153 | return NULL; |
| 154 | } |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 155 | |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 156 | /* call openlog if no current identifier */ |
| 157 | if (!S_ident_o) { |
| 158 | PyObject *openargs; |
| 159 | |
| 160 | /* Continue even if PyTuple_New fails, because openlog(3) is optional. |
| 161 | * So, we can still do loggin in the unlikely event things are so hosed |
| 162 | * that we can't do this tuple. |
| 163 | */ |
| 164 | if ((openargs = PyTuple_New(0))) { |
| 165 | PyObject *openlog_ret = syslog_openlog(self, openargs, NULL); |
| 166 | Py_XDECREF(openlog_ret); |
| 167 | Py_DECREF(openargs); |
| 168 | } |
| 169 | } |
| 170 | |
Christian Heimes | f0476e8 | 2008-02-23 17:42:31 +0000 | [diff] [blame] | 171 | Py_BEGIN_ALLOW_THREADS; |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 172 | syslog(priority, "%s", message); |
Christian Heimes | f0476e8 | 2008-02-23 17:42:31 +0000 | [diff] [blame] | 173 | Py_END_ALLOW_THREADS; |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 174 | Py_INCREF(Py_None); |
| 175 | return Py_None; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 178 | static PyObject * |
Georg Brandl | 96a8c39 | 2006-05-29 21:04:52 +0000 | [diff] [blame] | 179 | syslog_closelog(PyObject *self, PyObject *unused) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 180 | { |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 181 | closelog(); |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 182 | Py_XDECREF(S_ident_o); |
| 183 | S_ident_o = NULL; |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 184 | Py_INCREF(Py_None); |
| 185 | return Py_None; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 188 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 189 | syslog_setlogmask(PyObject *self, PyObject *args) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 190 | { |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 191 | long maskpri, omaskpri; |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 192 | |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 193 | if (!PyArg_ParseTuple(args, "l;mask for priority", &maskpri)) |
| 194 | return NULL; |
| 195 | omaskpri = setlogmask(maskpri); |
| 196 | return PyInt_FromLong(omaskpri); |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 199 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 200 | syslog_log_mask(PyObject *self, PyObject *args) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 201 | { |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 202 | long mask; |
| 203 | long pri; |
Guido van Rossum | 43713e5 | 2000-02-29 13:59:29 +0000 | [diff] [blame] | 204 | if (!PyArg_ParseTuple(args, "l:LOG_MASK", &pri)) |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 205 | return NULL; |
| 206 | mask = LOG_MASK(pri); |
| 207 | return PyInt_FromLong(mask); |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 208 | } |
| 209 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 210 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 211 | syslog_log_upto(PyObject *self, PyObject *args) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 212 | { |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 213 | long mask; |
| 214 | long pri; |
Guido van Rossum | 43713e5 | 2000-02-29 13:59:29 +0000 | [diff] [blame] | 215 | if (!PyArg_ParseTuple(args, "l:LOG_UPTO", &pri)) |
Barry Warsaw | 43a476a | 1997-01-09 23:51:21 +0000 | [diff] [blame] | 216 | return NULL; |
| 217 | mask = LOG_UPTO(pri); |
| 218 | return PyInt_FromLong(mask); |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /* List of functions defined in the module */ |
| 222 | |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 223 | static PyMethodDef syslog_methods[] = { |
Sean Reifscheider | f6ce3cb | 2010-04-23 08:31:55 +0000 | [diff] [blame] | 224 | {"openlog", (PyCFunction) syslog_openlog, METH_VARARGS | METH_KEYWORDS}, |
Georg Brandl | 96a8c39 | 2006-05-29 21:04:52 +0000 | [diff] [blame] | 225 | {"closelog", syslog_closelog, METH_NOARGS}, |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 226 | {"syslog", syslog_syslog, METH_VARARGS}, |
| 227 | {"setlogmask", syslog_setlogmask, METH_VARARGS}, |
| 228 | {"LOG_MASK", syslog_log_mask, METH_VARARGS}, |
| 229 | {"LOG_UPTO", syslog_log_upto, METH_VARARGS}, |
| 230 | {NULL, NULL, 0} |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 231 | }; |
| 232 | |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 233 | /* Initialization function for the module */ |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 234 | |
Mark Hammond | fe51c6d | 2002-08-02 02:27:13 +0000 | [diff] [blame] | 235 | PyMODINIT_FUNC |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 236 | initsyslog(void) |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 237 | { |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 238 | PyObject *m; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 239 | |
| 240 | /* Create the module and add the functions */ |
Guido van Rossum | f6971e2 | 1994-08-30 12:25:20 +0000 | [diff] [blame] | 241 | m = Py_InitModule("syslog", syslog_methods); |
Neal Norwitz | 1ac754f | 2006-01-19 06:09:39 +0000 | [diff] [blame] | 242 | if (m == NULL) |
| 243 | return; |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 244 | |
| 245 | /* Add some symbolic constants to the module */ |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 246 | |
| 247 | /* Priorities */ |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 248 | PyModule_AddIntConstant(m, "LOG_EMERG", LOG_EMERG); |
| 249 | PyModule_AddIntConstant(m, "LOG_ALERT", LOG_ALERT); |
| 250 | PyModule_AddIntConstant(m, "LOG_CRIT", LOG_CRIT); |
| 251 | PyModule_AddIntConstant(m, "LOG_ERR", LOG_ERR); |
| 252 | PyModule_AddIntConstant(m, "LOG_WARNING", LOG_WARNING); |
| 253 | PyModule_AddIntConstant(m, "LOG_NOTICE", LOG_NOTICE); |
| 254 | PyModule_AddIntConstant(m, "LOG_INFO", LOG_INFO); |
| 255 | PyModule_AddIntConstant(m, "LOG_DEBUG", LOG_DEBUG); |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 256 | |
| 257 | /* openlog() option flags */ |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 258 | PyModule_AddIntConstant(m, "LOG_PID", LOG_PID); |
| 259 | PyModule_AddIntConstant(m, "LOG_CONS", LOG_CONS); |
| 260 | PyModule_AddIntConstant(m, "LOG_NDELAY", LOG_NDELAY); |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 261 | #ifdef LOG_NOWAIT |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 262 | PyModule_AddIntConstant(m, "LOG_NOWAIT", LOG_NOWAIT); |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 263 | #endif |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 264 | #ifdef LOG_PERROR |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 265 | PyModule_AddIntConstant(m, "LOG_PERROR", LOG_PERROR); |
Guido van Rossum | c1822a4 | 1995-10-11 16:15:28 +0000 | [diff] [blame] | 266 | #endif |
| 267 | |
| 268 | /* Facilities */ |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 269 | PyModule_AddIntConstant(m, "LOG_KERN", LOG_KERN); |
| 270 | PyModule_AddIntConstant(m, "LOG_USER", LOG_USER); |
| 271 | PyModule_AddIntConstant(m, "LOG_MAIL", LOG_MAIL); |
| 272 | PyModule_AddIntConstant(m, "LOG_DAEMON", LOG_DAEMON); |
| 273 | PyModule_AddIntConstant(m, "LOG_AUTH", LOG_AUTH); |
| 274 | PyModule_AddIntConstant(m, "LOG_LPR", LOG_LPR); |
| 275 | PyModule_AddIntConstant(m, "LOG_LOCAL0", LOG_LOCAL0); |
| 276 | PyModule_AddIntConstant(m, "LOG_LOCAL1", LOG_LOCAL1); |
| 277 | PyModule_AddIntConstant(m, "LOG_LOCAL2", LOG_LOCAL2); |
| 278 | PyModule_AddIntConstant(m, "LOG_LOCAL3", LOG_LOCAL3); |
| 279 | PyModule_AddIntConstant(m, "LOG_LOCAL4", LOG_LOCAL4); |
| 280 | PyModule_AddIntConstant(m, "LOG_LOCAL5", LOG_LOCAL5); |
| 281 | PyModule_AddIntConstant(m, "LOG_LOCAL6", LOG_LOCAL6); |
| 282 | PyModule_AddIntConstant(m, "LOG_LOCAL7", LOG_LOCAL7); |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 283 | |
Guido van Rossum | ae94cf2 | 1998-05-08 21:52:55 +0000 | [diff] [blame] | 284 | #ifndef LOG_SYSLOG |
| 285 | #define LOG_SYSLOG LOG_DAEMON |
| 286 | #endif |
| 287 | #ifndef LOG_NEWS |
| 288 | #define LOG_NEWS LOG_MAIL |
| 289 | #endif |
| 290 | #ifndef LOG_UUCP |
| 291 | #define LOG_UUCP LOG_MAIL |
| 292 | #endif |
| 293 | #ifndef LOG_CRON |
| 294 | #define LOG_CRON LOG_DAEMON |
| 295 | #endif |
| 296 | |
Fred Drake | 4baedc1 | 2002-04-01 14:53:37 +0000 | [diff] [blame] | 297 | PyModule_AddIntConstant(m, "LOG_SYSLOG", LOG_SYSLOG); |
| 298 | PyModule_AddIntConstant(m, "LOG_CRON", LOG_CRON); |
| 299 | PyModule_AddIntConstant(m, "LOG_UUCP", LOG_UUCP); |
| 300 | PyModule_AddIntConstant(m, "LOG_NEWS", LOG_NEWS); |
Guido van Rossum | e44e373 | 1994-07-14 13:56:50 +0000 | [diff] [blame] | 301 | } |