From b52939ccfedf2b4e536f103cd883f61b19cf67a9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 27 Sep 2011 16:40:50 +0200 Subject: [PATCH] only debug if __debug is setup Signed-off-by: Nico Schottelius --- lib/cdist/config.py | 3 ++- lib/cdist/emulator.py | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/cdist/config.py b/lib/cdist/config.py index 6df5d6d8..af47d091 100644 --- a/lib/cdist/config.py +++ b/lib/cdist/config.py @@ -150,7 +150,8 @@ class Config: env['__global'] = self.path.out_dir # Submit debug flag to manifest, can be used by emulator and types - env['__debug'] = "yes" + if self.debug: + env['__debug'] = "yes" # Required for recording source env['__cdist_manifest'] = manifest diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index d69694df..38a58f8c 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -38,21 +38,19 @@ def run(argv): if '__debug' in os.environ: logging.root.setLevel(logging.DEBUG) + else: + logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser(add_help=False) - # Setup optional parameters for parameter in cdist.path.file_to_list(os.path.join(param_dir, "optional")): argument = "--" + parameter parser.add_argument(argument, action='store', required=False) - - # Setup required parameters for parameter in cdist.path.file_to_list(os.path.join(param_dir, "required")): argument = "--" + parameter parser.add_argument(argument, action='store', required=True) - # Setup positional parameter, if not singleton - + # If not singleton support one positional parameter if not os.path.isfile(os.path.join(type_dir, "singleton")): parser.add_argument("object_id", nargs=1) @@ -70,6 +68,10 @@ def run(argv): if object_id[0] == '/': object_id = object_id[1:] + # Prefix output by object_self + logformat = '%(levelname)s: ' + type + '/' + object_id + ': %(message)s' + logging.basicConfig(format=logformat) + # FIXME: verify object id log.debug(args)