mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
netcmd: Add Command.get_logger() method.
This commit is contained in:
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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.")
|
||||
|
Reference in New Issue
Block a user