Merge branch 'master' of ssh://bakers@git.planet-lab.org/git/sfa
authorsmbaker <smbaker@fc8clean.lan>
Thu, 7 Jul 2011 18:04:25 +0000 (11:04 -0700)
committersmbaker <smbaker@fc8clean.lan>
Thu, 7 Jul 2011 18:04:25 +0000 (11:04 -0700)
1  2 
sfa/util/sfalogging.py

diff --combined sfa/util/sfalogging.py
index 93e3073,199066d..3ec0350
mode 100644,100755..100644
@@@ -28,6 -28,14 +28,14 @@@ class _SfaLogger
              # This is usually a permissions error becaue the file is
              # owned by root, but httpd is trying to access it.
              tmplogfile=os.getenv("TMPDIR", "/tmp") + os.path.sep + os.path.basename(logfile)
+             # In strange uses, 2 users on same machine might use same code,
+             # meaning they would clobber each others files
+             # We could (a) rename the tmplogfile, or (b)
+             # just log to the console in that case.
+             # Here we default to the console.
+             if os.path.exists(tmplogfile) and not os.access(tmplogfile,os.W_OK):
+                 loggername = loggername + "-console"
+                 handler = logging.StreamHandler()
              handler=logging.handlers.RotatingFileHandler(tmplogfile,maxBytes=1000000, backupCount=5) 
          handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
          self.logger=logging.getLogger(loggername)
          
      def warn(self, msg):
          self.logger.warn(msg)
 +
 +    # some code is using logger.warn(), some is using logger.warning()
 +    def warning(self, msg):
 +        self.logger.warning(msg)
     
      def error(self, msg):
          self.logger.error(msg)