summaryrefslogtreecommitdiffstats
path: root/source/python/py_common.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-04-11 05:04:05 +0000
committerTim Potter <tpot@samba.org>2002-04-11 05:04:05 +0000
commit6c7b5e15c22119623ee959267d2755e21193bc4b (patch)
treea6e0f88acf4b305db01c69529fe65ff62f98e580 /source/python/py_common.c
parent8bb798ab3d7245e61530913d771d58f08e77a200 (diff)
downloadsamba-6c7b5e15c22119623ee959267d2755e21193bc4b.tar.gz
samba-6c7b5e15c22119623ee959267d2755e21193bc4b.tar.xz
samba-6c7b5e15c22119623ee959267d2755e21193bc4b.zip
Implemented a setup_logging() function that takes two keywords:
interactive and logfilename. These can be used to send Samba DEBUG() output to stdout or to a logfile which makes automated testing much funkier. Also added get_debuglevel() and set_debuglevel() functions.
Diffstat (limited to 'source/python/py_common.c')
-rw-r--r--source/python/py_common.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/source/python/py_common.c b/source/python/py_common.c
index 5c2e0f896cd..bc3153c26cc 100644
--- a/source/python/py_common.c
+++ b/source/python/py_common.c
@@ -46,10 +46,6 @@ void py_samba_init(void)
if (initialised)
return;
- /* FIXME: logging doesn't work very well */
-
- setup_logging("python", True);
-
/* Load configuration file */
if (!lp_load(dyn_CONFIGFILE, True, False, False))
@@ -58,7 +54,64 @@ void py_samba_init(void)
/* Misc other stuff */
load_interfaces();
- DEBUGLEVEL = 10;
initialised = True;
}
+
+/* Debuglevel routines */
+
+PyObject *get_debuglevel(PyObject *self, PyObject *args)
+{
+ PyObject *debuglevel;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ debuglevel = PyInt_FromLong(DEBUGLEVEL);
+
+ return debuglevel;
+}
+
+PyObject *set_debuglevel(PyObject *self, PyObject *args)
+{
+ int debuglevel;
+
+ if (!PyArg_ParseTuple(args, "i", &debuglevel))
+ return NULL;
+
+ DEBUGLEVEL = debuglevel;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/* Initialise logging */
+
+PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw)
+{
+ BOOL interactive = False;
+ char *logfilename = NULL;
+ static char *kwlist[] = {"interactive", "logfilename", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "|is", kwlist,
+ &interactive, &logfilename))
+ return NULL;
+
+ if (interactive && logfilename) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "can't be interactive and set log file name");
+ return NULL;
+ }
+
+ if (interactive)
+ setup_logging("spoolss", True);
+
+ if (logfilename) {
+ lp_set_logfile(logfilename);
+ setup_logging(logfilename, False);
+ reopen_logs();
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}