diff --git a/moban/constants.py b/moban/constants.py index a139ffb1..169cbe15 100644 --- a/moban/constants.py +++ b/moban/constants.py @@ -70,6 +70,7 @@ LABEL_DEST = "destination" LABEL_FORCE_TEMPLATE_TYPE = "force_template_type" LABEL_TEMPLATE_TYPES = "template_types" +LABEL_DEBUG = "debug" # error messages ERROR_DATA_FILE_NOT_FOUND = "Both %s and %s does not exist" diff --git a/moban/main.py b/moban/main.py index 75eec3d0..c5950400 100644 --- a/moban/main.py +++ b/moban/main.py @@ -11,6 +11,7 @@ import sys import logging import argparse +import logging.config from moban import plugins, reporter, constants, mobanfile, exceptions from moban.utils import merge @@ -28,6 +29,12 @@ def main(): parser = create_parser() options = vars(parser.parse_args()) HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] + if options[constants.LABEL_DEBUG]: + logging.basicConfig( + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + level=logging.DEBUG, + ) + moban_file = options[constants.LABEL_MOBANFILE] load_engine_factory_and_engines() # Error: jinja2 if removed if moban_file is None: @@ -126,6 +133,13 @@ def create_parser(): action="version", version="%(prog)s {v}".format(v=__version__), ) + parser.add_argument( + "-d", + action="store_true", + dest=constants.LABEL_DEBUG, + default=False, + help="to show debug trace", + ) return parser diff --git a/moban/mobanfile/templates.py b/moban/mobanfile/templates.py index 80e3f6c5..73240e38 100644 --- a/moban/mobanfile/templates.py +++ b/moban/mobanfile/templates.py @@ -7,6 +7,7 @@ def handle_template(template_file, output, template_dirs): log.info("handling %s" % template_file) + template_file = file_system.to_unicode(template_file) multi_fs = file_system.get_multi_fs(template_dirs) if template_file.endswith("**"):