Setting tag nodemanager-1.8-39
[nodemanager.git] / logger.py
index bfc416b..17ae04c 100644 (file)
--- a/logger.py
+++ b/logger.py
@@ -21,6 +21,7 @@ LOG_VERBOSE=2
 LOG_LEVEL=1
 
 def set_level(level):
+    global LOG_LEVEL
     assert level in [LOG_NONE,LOG_NODE,LOG_VERBOSE]
     LOG_LEVEL=level
 
@@ -42,7 +43,12 @@ def log(msg,level=LOG_NODE):
 
 def log_call(*args):
     log('running command %s' % ' '.join(args))
-    try: subprocess.call(args, close_fds=True)
+    try: 
+        child = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+        child.wait() # wait for proc to hang up
+        if child.returncode:
+                raise Exception("command failed:\n stdout - %s\n stderr - %s" % \
+                        (child.stdout.readlines(), child.stderr.readlines()))
     except: log_exc()
 
 def log_exc(name = None):
@@ -56,7 +62,7 @@ def log_slivers (data):
     import pprint, time
     try:
         f=open(LOG_SLIVERS,'w')
-        now=time.strftime("GetSlivers stored at %H:%M:%S", time.localtime())
+        now=time.strftime("GetSlivers stored on %Y.%m.%d at %H:%M:%S", time.localtime())
         f.write(now+'\n')
         pp=pprint.PrettyPrinter(stream=f,indent=2)
         pp.pprint(data)