From 93f5ace932aa68e10947ae00a61ab99778fe3633 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Sep 2013 10:49:11 +0200 Subject: [PATCH] clenaup logging in emulator, cleanup emulator in main script Signed-off-by: Nico Schottelius --- cdist/emulator.py | 17 +---------------- scripts/cdist | 10 +++------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index 5b0ff1f6..8d7b0854 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -63,18 +63,6 @@ class Emulator(object): self.__init_log() - def filter(self, record): - """Add hostname and object to logs via logging Filter""" - - prefix = self.target_host + ": (emulator)" - prefix = '{0}: emulator {1}'.format( - self.target_host, - core.CdistObject.join_name(self.type_name, self.object_id) - ) - record.msg = prefix + ": " + record.msg - - return True - def run(self): """Emulate type commands (i.e. __file and co)""" @@ -87,16 +75,13 @@ class Emulator(object): def __init_log(self): """Setup logging facility""" - logformat = '%(levelname)s: %(message)s' - logging.basicConfig(format=logformat) if '__cdist_debug' in self.env: logging.root.setLevel(logging.DEBUG) else: logging.root.setLevel(logging.INFO) - self.log = logging.getLogger(__name__) - self.log.addFilter(self) + self.log = logging.getLogger(self.target_host) def commandline(self): """Parse command line""" diff --git a/scripts/cdist b/scripts/cdist index 6f6f13fe..38ff5cb2 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -122,12 +122,6 @@ def commandline(): args.func(args) -def emulator(): - """Prepare and run emulator""" - import cdist.emulator - emulator = cdist.emulator.Emulator(sys.argv) - return emulator.run() - if __name__ == "__main__": # Sys is needed for sys.exit() import sys @@ -153,7 +147,9 @@ if __name__ == "__main__": log = logging.getLogger("cdist") if re.match("__", os.path.basename(sys.argv[0])): - emulator() + import cdist.emulator + emulator = cdist.emulator.Emulator(sys.argv) + emulator.run() else: commandline()