diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2011-10-12 23:21:52 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2011-10-13 00:23:39 +0200 |
commit | 6f9a3177d49d49d9a631cb1f2219761a4721b387 (patch) | |
tree | 949d424bf1bbf1d439d6c2e24971583f42aac24c /source4/scripting/python | |
parent | 63c9186e92ae2c7f1f7383352cc95d38b2efc45a (diff) | |
download | samba-6f9a3177d49d49d9a631cb1f2219761a4721b387.tar.gz samba-6f9a3177d49d49d9a631cb1f2219761a4721b387.tar.bz2 samba-6f9a3177d49d49d9a631cb1f2219761a4721b387.zip |
netcmd: Add Command.get_logger() method.
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/netcmd/__init__.py | 6 | ||||
-rw-r--r-- | source4/scripting/python/samba/netcmd/domain.py | 3 | ||||
-rwxr-xr-x | source4/scripting/python/samba/netcmd/testparm.py | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index 3acd1022bf..49e03800d6 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -141,6 +141,12 @@ class Command(object): """Run the command. This should be overriden by all subclasses.""" raise NotImplementedError(self.run) + def get_logger(self, name="netcmd"): + """Get a logger object.""" + import logging + logger = logging.getLogger(name) + logger.addHandler(logging.StreamHandler(self.outf)) + return logger class SuperCommand(Command): diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py index f1125b2ce4..05e82b5dfa 100644 --- a/source4/scripting/python/samba/netcmd/domain.py +++ b/source4/scripting/python/samba/netcmd/domain.py @@ -573,8 +573,7 @@ samba3 testparm utility (with --testparm).""" self.outf.write("warning: both libdir and testparm specified, ignoring libdir.\n") libdir = None - logger = logging.getLogger("upgrade") - logger.addHandler(logging.StreamHandler(sys.stdout)) + logger = self.get_logger() if quiet: logger.setLevel(logging.WARNING) else: diff --git a/source4/scripting/python/samba/netcmd/testparm.py b/source4/scripting/python/samba/netcmd/testparm.py index 08d21721c7..b9979770e6 100755 --- a/source4/scripting/python/samba/netcmd/testparm.py +++ b/source4/scripting/python/samba/netcmd/testparm.py @@ -36,7 +36,6 @@ import os import sys -import logging import samba import samba.getopt as options @@ -93,8 +92,7 @@ class cmd_testparm(Command): # We need this to force the output samba.set_debug_level(2) - logger = logging.getLogger("testparm") - logger.addHandler(logging.StreamHandler(sys.stdout)) + logger = self.get_logger("testparm") logger.info("Loaded smb config files from %s", lp.configfile) logger.info("Loaded services file OK.") |