git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d1c9213
)
fix possible IOError (pemission denied) 2 users are writing to the same log file
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Thu, 7 Jul 2011 18:04:11 +0000
(14:04 -0400)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Thu, 7 Jul 2011 18:04:11 +0000
(14:04 -0400)
sfa/util/sfalogging.py
patch
|
blob
|
history
diff --git
a/sfa/util/sfalogging.py
b/sfa/util/sfalogging.py
index
3991d33
..
199066d
100755
(executable)
--- 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)
# 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)
handler=logging.handlers.RotatingFileHandler(tmplogfile,maxBytes=1000000, backupCount=5)
handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
self.logger=logging.getLogger(loggername)