1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

netcmd: apply the new get_logger to cmds

This is an example of how to use the new logger.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joe Guo 2018-08-21 12:45:15 +12:00 committed by Douglas Bagnall
parent 0979d96006
commit 126a14b443
3 changed files with 7 additions and 48 deletions

View File

@ -1104,13 +1104,7 @@ class cmd_cleanup_record(Command):
lp = sambaopts.get_loadparm() lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
samdb = SamDB(url="ldap://%s" % server, samdb = SamDB(url="ldap://%s" % server,
session_info=system_session(), session_info=system_session(),

View File

@ -368,11 +368,7 @@ class cmd_domain_provision(Command):
plaintext_secrets=False, plaintext_secrets=False,
backend_store=None): backend_store=None):
self.logger = self.get_logger("provision") self.logger = self.get_logger(name="provision", quiet=quiet)
if quiet:
self.logger.setLevel(logging.WARNING)
else:
self.logger.setLevel(logging.INFO)
lp = sambaopts.get_loadparm() lp = sambaopts.get_loadparm()
smbconf = lp.configfile smbconf = lp.configfile
@ -616,13 +612,7 @@ class cmd_domain_dcpromo(Command):
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress) net = Net(creds, lp, server=credopts.ipaddress)
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
netbios_name = lp.get("netbios name") netbios_name = lp.get("netbios name")
@ -688,13 +678,7 @@ class cmd_domain_join(Command):
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress) net = Net(creds, lp, server=credopts.ipaddress)
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
netbios_name = lp.get("netbios name") netbios_name = lp.get("netbios name")
@ -771,13 +755,7 @@ class cmd_domain_demote(Command):
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress) net = Net(creds, lp, server=credopts.ipaddress)
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
if remove_other_dead_server is not None: if remove_other_dead_server is not None:
if server is not None: if server is not None:
@ -1615,13 +1593,7 @@ class cmd_domain_classicupgrade(Command):
if not dbdir and not testparm: if not dbdir and not testparm:
raise CommandError("Please specify either dbdir or testparm") raise CommandError("Please specify either dbdir or testparm")
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
if dbdir and testparm: if dbdir and testparm:
logger.warning("both dbdir and testparm specified, ignoring dbdir.") logger.warning("both dbdir and testparm specified, ignoring dbdir.")

View File

@ -38,7 +38,6 @@ from samba.join import join_clone
from samba.ndr import ndr_unpack from samba.ndr import ndr_unpack
from samba.dcerpc import drsblobs from samba.dcerpc import drsblobs
from samba import colour from samba import colour
import logging
def drsuapi_connect(ctx): def drsuapi_connect(ctx):
@ -760,13 +759,7 @@ class cmd_drs_clone_dc_database(Command):
lp = sambaopts.get_loadparm() lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp) creds = credopts.get_credentials(lp)
logger = self.get_logger() logger = self.get_logger(verbose=verbose, quiet=quiet)
if verbose:
logger.setLevel(logging.DEBUG)
elif quiet:
logger.setLevel(logging.WARNING)
else:
logger.setLevel(logging.INFO)
if targetdir is None: if targetdir is None:
raise CommandError("--targetdir option must be specified") raise CommandError("--targetdir option must be specified")