summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2013-04-17 09:42:55 -0700
committerScott Moser <smoser@brickies.net>2013-04-17 09:42:55 -0700
commit66ea1ae9599d27686db2510f3a079485ea8292c3 (patch)
treed927b3c0b3686e4dad9a20869f94202cd139392b
parentb9c6f197b6865987e9cdd2cd71fa1a5a9dff11c5 (diff)
downloadvyos-cloud-init-66ea1ae9599d27686db2510f3a079485ea8292c3.tar.gz
vyos-cloud-init-66ea1ae9599d27686db2510f3a079485ea8292c3.zip
add debug output to ccfg-merge-debug
Exeptions were being swallowed completely and no way to even see them other than log.
-rw-r--r--cloudinit/log.py6
-rwxr-xr-xtools/ccfg-merge-debug8
2 files changed, 11 insertions, 3 deletions
diff --git a/cloudinit/log.py b/cloudinit/log.py
index da6c2851..622c946c 100644
--- a/cloudinit/log.py
+++ b/cloudinit/log.py
@@ -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):
diff --git a/tools/ccfg-merge-debug b/tools/ccfg-merge-debug
index aac60528..5b6b050a 100755
--- a/tools/ccfg-merge-debug
+++ b/tools/ccfg-merge-debug
@@ -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"