configure logging inline, after parsing the command line options
addresses bug #60
This commit is contained in:
parent
525c52573f
commit
a173e6e668
@ -1,28 +0,0 @@
|
||||
# http://docs.python.org/dev/library/logging.config.html
|
||||
|
||||
[default]
|
||||
|
||||
[loggers]
|
||||
keys=root
|
||||
|
||||
[logger_root]
|
||||
level=INFO
|
||||
handlers=hand01
|
||||
formatter=form01
|
||||
|
||||
[handlers]
|
||||
keys=hand01
|
||||
|
||||
[handler_hand01]
|
||||
class=devstack.log.StreamHandler
|
||||
formatter=form01
|
||||
args=(sys.stdout,)
|
||||
|
||||
[formatters]
|
||||
keys=form01
|
||||
|
||||
[formatter_form01]
|
||||
format=%(levelname)s: @%(name)s : %(message)s
|
||||
class=devstack.colorlog.TermFormatter
|
||||
|
||||
|
@ -31,7 +31,7 @@ COLOR_ATTRS = {
|
||||
|
||||
|
||||
class TermFormatter(logging.Formatter):
|
||||
def __init__(self, reg_fmt, date_format):
|
||||
def __init__(self, reg_fmt=None, date_format=None):
|
||||
logging.Formatter.__init__(self, reg_fmt, date_format)
|
||||
|
||||
def format(self, record):
|
||||
|
22
stack
22
stack
@ -23,17 +23,11 @@ import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from devstack import settings
|
||||
|
||||
#this needs to happen immediately (or thats what it seems)
|
||||
LOG_FN = os.getenv(settings.STACK_LOG_ENV_LOCATION)
|
||||
if not LOG_FN or not os.path.isfile(LOG_FN):
|
||||
LOG_FN = settings.STACK_LOG_CFG_LOCATION
|
||||
logging.config.fileConfig(LOG_FN)
|
||||
|
||||
from devstack import colorlog
|
||||
from devstack import date
|
||||
from devstack import log as lg
|
||||
from devstack import opts
|
||||
from devstack import settings
|
||||
from devstack import shell as sh
|
||||
from devstack import utils
|
||||
|
||||
@ -117,9 +111,17 @@ def main():
|
||||
args = opts.parse()
|
||||
prog_name = sys.argv[0]
|
||||
|
||||
# Configure logging
|
||||
root_logger = logging.getLogger('')
|
||||
root_logger.setLevel(logging.DEBUG)
|
||||
console = logging.StreamHandler(sys.stdout)
|
||||
console_format = '%(levelname)s: @%(name)s : %(message)s'
|
||||
console.setFormatter(colorlog.TermFormatter(console_format))
|
||||
root_logger.addHandler(console)
|
||||
|
||||
# Adjust logging verbose level based on the command line switch.
|
||||
if args['verbosity'] >= 2:
|
||||
lg.getLogger().setLevel(logging.DEBUG)
|
||||
log_level = logging.DEBUG if args['verbosity'] >= 2 else logging.INFO
|
||||
root_logger.setLevel(log_level)
|
||||
LOG.debug("Command line options %s" % (args))
|
||||
|
||||
#will need root to setup openstack
|
||||
|
Loading…
Reference in New Issue
Block a user