check log file mode prior to chmod

This commit is contained in:
vladimir.p
2011-08-24 08:51:14 -07:00
parent bd573ed1cf
commit 38273c8123

View File

@@ -257,7 +257,11 @@ class NovaRootLogger(NovaLogger):
self.filelog = WatchedFileHandler(logpath)
self.addHandler(self.filelog)
self.logpath = logpath
os.chmod(self.logpath, FLAGS.logfile_mode)
import stat
st = os.stat(self.logpath)
if st.st_mode != (stat.S_IFREG | FLAGS.logfile_mode):
os.chmod(self.logpath, FLAGS.logfile_mode)
else:
self.removeHandler(self.filelog)
self.addHandler(self.streamlog)