From 4817145ef8e9cb38703d487dc457fe44b2a3ac2d Mon Sep 17 00:00:00 2001 From: Mathias Klette Date: Wed, 5 Jun 2013 21:46:08 +0200 Subject: [PATCH] common_code: shorten log_name if not explicitely given --- common_code.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common_code.py b/common_code.py index 2b01ffc..6748f56 100755 --- a/common_code.py +++ b/common_code.py @@ -5,6 +5,7 @@ import datetime import logging import os import platform +import re import subprocess import sys from logging import Formatter @@ -15,11 +16,14 @@ def figlet(text = None): subprocess.check_call(cmd) def logger_init( - log_name = __file__, - log_format = '%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s', + log_name = None, + log_format = '%(asctime)s %(name)s [%(process)d] %(levelname)s: %(message)s', log_level = None, ): + if log_name == None: + log_name = re.match('^(.*/jenkins_build_script/)(.*)',__name__).groups()[1] + if log_level == None: try: if ENV['GIT_BRANCH'] == 'master': -- 2.39.5