X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fsfalogging.py;h=3ec03506bb1926c510b09f817e85920e201e29e3;hb=3fef415cbd03da2d4a042f8450d564e68ed312f4;hp=3991d338dbe405917bf355a3161103bcba7b67a8;hpb=b2d3e37b8c36a60f2449c235e0b4f7d2942e3292;p=sfa.git diff --git a/sfa/util/sfalogging.py b/sfa/util/sfalogging.py old mode 100755 new mode 100644 index 3991d338..3ec03506 --- a/sfa/util/sfalogging.py +++ b/sfa/util/sfalogging.py @@ -28,6 +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) @@ -71,6 +79,10 @@ class _SfaLogger: 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)