]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
common_code: shorten log_name if not explicitely given
authorMathias Klette <mathias.klette@profitbricks.com>
Wed, 5 Jun 2013 19:46:08 +0000 (21:46 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Wed, 5 Jun 2013 19:46:08 +0000 (21:46 +0200)
common_code.py

index 2b01ffccd22352e7f109d9d64eccf56467c45f54..6748f56dd03373c6d41e2f43ab9cb01cc0624f5f 100755 (executable)
@@ -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':