Browse Source

Modified exception handler

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac176@1963 e5f2f494-b856-4b98-b285-d166d9295462
Jerry 15 years ago
parent
commit
8cd3eaf955
1 changed files with 8 additions and 10 deletions
  1. 8 10
      src/lib/python/isc/log/log.py

+ 8 - 10
src/lib/python/isc/log/log.py

@@ -56,19 +56,17 @@ class RotatingFileHandler(logging.handlers.RotatingFileHandler):
         """
         Update RotatingFileHandler configuration.
 
+        If the file path is not exists, we will use the old configuration.
         input:
             log file name
             max backup count
             predetermined log file size
         """
-        try:
-            self._open(file_name)
-        except IOError:
-            print("The file path is not exist!")
-            return 
-        self.baseFilename = file_name
-        self.maxBytes = max_bytes
-        self.backupCount = backup_count
+        dir = os.path.split(file_name)
+        if(os.path.exists(dir[0])):
+            self.baseFilename = file_name
+            self.maxBytes = max_bytes
+            self.backupCount = backup_count
 
 class SLHandler(logging.Handler):    
     """
@@ -194,8 +192,8 @@ class ModuleLogger(logging.getLoggerClass()):
 
     def update_rotate_handler(self, log_file, max_bytes, backup_count):
         """
-        If rotate handler has been added to the logger, update its configuration,
-        else add it to logger.
+        If the rotate handler has been added to the logger, update its configuration,
+        else add it to the logger.
     
         If log file is empty, the handler will be removed.
         """