Jelajahi Sumber

Using logging instead of print statement in cleanup helper

Nuwan Goonasekera 4 tahun lalu
induk
melakukan
12717dd505
1 mengubah file dengan 5 tambahan dan 4 penghapusan
  1. 5 4
      cloudbridge/base/helpers.py

+ 5 - 4
cloudbridge/base/helpers.py

@@ -1,5 +1,6 @@
 import fnmatch
 import functools
+import logging
 import os
 import re
 import sys
@@ -18,6 +19,8 @@ import cloudbridge
 
 from ..interfaces.exceptions import InvalidParamException
 
+log = logging.getLogger(__name__)
+
 
 def generate_key_pair():
     """
@@ -103,14 +106,12 @@ def cleanup_action(cleanup_func):
         try:
             cleanup_func()
         except Exception as e:
-            print("Error during exception cleanup: {0}".format(e))
-            traceback.print_exc()
+            log.exception("Error during exception cleanup: ")
         six.reraise(ex_class, ex_val, ex_traceback)
     try:
         cleanup_func()
     except Exception as e:
-        print("Error during cleanup: {0}".format(e))
-        traceback.print_exc()
+        log.exception("Error during exception cleanup: ")
 
 
 def get_env(varname, default_value=None):