add debug output to ccfg-merge-debug
Exeptions were being swallowed completely and no way to even see them other than log.
This commit is contained in:
@@ -44,13 +44,13 @@ NOTSET = logging.NOTSET
|
||||
DEF_CON_FORMAT = '%(asctime)s - %(filename)s[%(levelname)s]: %(message)s'
|
||||
|
||||
|
||||
def setupBasicLogging():
|
||||
def setupBasicLogging(level=DEBUG):
|
||||
root = logging.getLogger()
|
||||
console = logging.StreamHandler(sys.stderr)
|
||||
console.setFormatter(logging.Formatter(DEF_CON_FORMAT))
|
||||
console.setLevel(DEBUG)
|
||||
console.setLevel(level)
|
||||
root.addHandler(console)
|
||||
root.setLevel(DEBUG)
|
||||
root.setLevel(level)
|
||||
|
||||
|
||||
def flushLoggers(root):
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from cloudinit import handlers
|
||||
from cloudinit.handlers import cloud_config as cc_part
|
||||
from cloudinit import helpers
|
||||
from cloudinit import log as logging
|
||||
from cloudinit.settings import PER_INSTANCE
|
||||
from cloudinit import user_data as ud
|
||||
|
||||
@@ -17,9 +18,16 @@ def main():
|
||||
description='test cloud-config merging')
|
||||
parser.add_argument("--output", "-o", metavar="file",
|
||||
help="specify output file", default="-")
|
||||
parser.add_argument('--verbose', '-v', action='count', default=0)
|
||||
parser.add_argument('files', nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.verbose:
|
||||
level = (logging.WARN, logging.INFO,
|
||||
logging.DEBUG)[min(args.verbose, 2)]
|
||||
logging.setupBasicLogging(level)
|
||||
|
||||
outfile = args.output
|
||||
if args.output == "-":
|
||||
outfile = "/dev/stdout"
|
||||
|
||||
Reference in New Issue
Block a user