Move _configure_logging to base Command class

The _configure_logging method is moved to the base Command class so it
can be more easily used by any command.

Change-Id: I1bce6c2d0d76e30bc3a2ee802a4528fc60046d33
Signed-off-by: James Slagle <jslagle@redhat.com>
This commit is contained in:
James Slagle 2021-12-22 08:10:03 -05:00
parent 0c48816539
commit b682efb9c0
2 changed files with 12 additions and 12 deletions

View File

@ -83,6 +83,17 @@ class Command(command.Command):
return parsed_args.overcloud_ssh_key
def _configure_logging(self, parsed_args):
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
self.log.addHandler(handler)
if self.app_args.verbose_level >= 2:
handler.setLevel(logging.DEBUG)
else:
handler.setLevel(logging.INFO)
class Lister(Command, command.Lister):
pass

View File

@ -18,9 +18,9 @@ import getpass
import logging
import os
from cliff import command
from osc_lib.i18n import _
from tripleoclient import command
from tripleoclient.constants import (DEFAULT_EPHEMERAL_HEAT_CONTAINER,
DEFAULT_EPHEMERAL_HEAT_API_CONTAINER,
DEFAULT_EPHEMERAL_HEAT_ENGINE_CONTAINER)
@ -221,14 +221,3 @@ class LaunchHeat(command.Command):
else:
self.log.info("Writing heat clouds.yaml")
utils.write_ephemeral_heat_clouds_yaml(parsed_args.heat_dir)
def _configure_logging(self, parsed_args):
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
self.log.addHandler(handler)
if self.app_args.verbose_level >= 2:
handler.setLevel(logging.DEBUG)
else:
handler.setLevel(logging.INFO)