diff options
Diffstat (limited to 'source4/scripting')
-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.") |