]> Frank Brehm's Git Trees - my-stuff/py-logrotate.git/commitdiff
Logging korrigiert für Python 2.5
authorFrank Brehm <frank@brehm-online.com>
Tue, 5 Jul 2011 11:45:11 +0000 (11:45 +0000)
committerFrank Brehm <frank@brehm-online.com>
Tue, 5 Jul 2011 11:45:11 +0000 (11:45 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/python/PyLogrotate/trunk@279 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

LogRotateConfig.py
LogRotateHandler.py
LogRotateScript.py
LogRotateStatusFile.py

index 5ede5016ffd30de7d146f2ea0cdd7d86ec21625a..a9fd6038130ee3d79974dd715f75517e47235dc7 100755 (executable)
@@ -22,6 +22,7 @@ import os.path
 import pwd
 import grp
 import glob
+import logging
 
 from LogRotateCommon import split_parts, email_valid, period2days, human2bytes
 from LogRotateScript import LogRotateScript
@@ -156,7 +157,6 @@ class LogrotateConfigurationReader(object):
     #-------------------------------------------------------
     def __init__( self, config_file,
                         verbose   = 0,
-                        logger    = None,
                         local_dir = None,
                         test_mode = False,
     ):
@@ -167,8 +167,6 @@ class LogrotateConfigurationReader(object):
         @type config_file:  str
         @param verbose:     verbosity (debug) level
         @type verbose:      int
-        @param logger:      logger object to use for logging a.s.o.
-        @type logger:       logging.getLogger or None
         @param local_dir:   The directory, where the i18n-files (*.mo)
                             are located. If None, then system default
                             (/usr/share/locale) is used.
@@ -215,7 +213,7 @@ class LogrotateConfigurationReader(object):
         @type: bool
         '''
 
-        self.logger = logger.getChild('config')
+        self.logger = logging.getLogger('pylogrotate.config')
         '''
         @ivar: logger object
         @type: logging.getLogger
@@ -227,34 +225,6 @@ class LogrotateConfigurationReader(object):
         @type: dict
         '''
 
-        if not logger:
-
-            #################################################
-            # Create a logger object, if necessary
-            self.logger = logging.getLogger('logrotate_cfg')
-
-            self.logger.setLevel(logging.DEBUG)
-
-            pp = pprint.PrettyPrinter(indent=4)
-            # create console handler and set level to debug
-            ch = logging.StreamHandler()
-            #ch.setLevel(logging.DEBUG)
-            if verbose:
-                ch.setLevel(logging.DEBUG)
-            else:
-                ch.setLevel(logging.INFO)
-
-            # create formatter
-            formatter = logging.Formatter(
-                '[%(asctime)s]: %(name)s %(levelname)-8s - %(message)s'
-            )
-
-            # add formatter to ch
-            ch.setFormatter(formatter)
-
-            # add ch to logger
-            self.logger.addHandler(ch)
-
         #############################################
         # the rest of instance variables:
 
index a82af362a55f485ccd9908e14e21b6e799ac7630..7a7e4a4dcca94225686ee0da5a5d5828fe5b8456 100755 (executable)
@@ -316,7 +316,6 @@ class LogrotateHandler(object):
             local_dir = self.local_dir,
             verbose   = self.verbose,
             test_mode = self.test,
-            logger    = self.logger,
         )
 
     #------------------------------------------------------------
@@ -427,7 +426,6 @@ class LogrotateHandler(object):
         config_reader = LogrotateConfigurationReader(
             config_file = self.config_file,
             verbose     = self.verbose,
-            logger      = self.logger,
             local_dir   = self.local_dir,
             test_mode   = self.test,
         )
index e4637fff432d92d5428df7d8fc159555c9e6b414..34268cae19cca5c9b91fbfe4080823826f5f9ab7 100755 (executable)
@@ -180,15 +180,6 @@ class LogRotateScript(object):
 
     name = property(_get_name, None, None, "Name of the script as an identifier")
 
-    #@property
-    #def name(self):
-    #    '''
-    #    Property 'name' as the name of the script as an identifier
-    #
-    #    readonly
-    #    '''
-    #    return self._name
-
     #------------------------------------------------------------
     # Property 'cmd'
     def _get_cmd(self):
index 782a9a4468424220ded48a09a73dc4a0ec4c6162..5dc4b3c32fc08be82ddaf714dae235a70a87bcde 100755 (executable)
@@ -77,7 +77,6 @@ class LogrotateStatusFile(object):
                         local_dir  = None,
                         verbose    = 0,
                         test_mode  = False,
-                        logger     = None,
     ):
         '''
         Constructor.
@@ -88,8 +87,6 @@ class LogrotateStatusFile(object):
         @type verbose:    int
         @param test_mode: test mode - no write actions are made
         @type test_mode:  bool
-        @param logger:    logger object to use for logging a.s.o.
-        @type logger:     logging.getLogger or None
         @param local_dir: The directory, where the i18n-files (*.mo)
                           are located. If None, then system default
                           (/usr/share/locale) is used.
@@ -164,7 +161,7 @@ class LogrotateStatusFile(object):
         @type: bool
         '''
 
-        self.logger = logger.getChild('status_file')
+        self.logger = logging.getLogger('pylogrotate.status_file')
         '''
         @ivar: logger object
         @type: logging.getLogger
@@ -180,34 +177,6 @@ class LogrotateStatusFile(object):
         @type: dict
         '''
 
-        if not logger:
-
-            #################################################
-            # Create a logger object, if necessary
-            self.logger = logging.getLogger('logrotate_state_file')
-
-            self.logger.setLevel(logging.DEBUG)
-
-            pp = pprint.PrettyPrinter(indent=4)
-            # create console handler and set level to debug
-            ch = logging.StreamHandler()
-            #ch.setLevel(logging.DEBUG)
-            if verbose:
-                ch.setLevel(logging.DEBUG)
-            else:
-                ch.setLevel(logging.INFO)
-
-            # create formatter
-            formatter = logging.Formatter(
-                '[%(asctime)s]: %(name)s %(levelname)-8s - %(message)s'
-            )
-
-            # add formatter to ch
-            ch.setFormatter(formatter)
-
-            # add ch to logger
-            self.logger.addHandler(ch)
-
         # Initial read and check for permissions
         self.read(must_exists = False)
         self._check_permissions()