~yolanda.robla/nova/precise-security

« back to all changes in this revision

Viewing changes to nova/log.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-02 10:56:30 UTC
  • mto: (79.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20111202105630-tjly1gpmdh533s0q
Tags: upstream-2012.1~e2~20111202.11641
ImportĀ upstreamĀ versionĀ 2012.1~e2~20111202.11641

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
flags.DEFINE_bool('use_syslog', False, 'output to syslog')
71
71
flags.DEFINE_bool('publish_errors', False, 'publish error events')
72
72
flags.DEFINE_string('logfile', None, 'output to named file')
 
73
flags.DEFINE_bool('use_stderr', True, 'log to standard error')
73
74
 
74
75
 
75
76
# A list of things we want to replicate from logging.
243
244
    def __init__(self, name, level=NOTSET):
244
245
        self.logpath = None
245
246
        self.filelog = None
246
 
        self.streamlog = StreamHandler()
 
247
        self.streamlog = None
247
248
        self.syslog = None
248
249
        NovaLogger.__init__(self, name, level)
249
250
 
258
259
            self.addHandler(self.syslog)
259
260
        logpath = _get_log_file_path()
260
261
        if logpath:
261
 
            self.removeHandler(self.streamlog)
262
262
            if logpath != self.logpath:
263
263
                self.removeHandler(self.filelog)
264
264
                self.filelog = WatchedFileHandler(logpath)
271
271
                    os.chmod(self.logpath, mode)
272
272
        else:
273
273
            self.removeHandler(self.filelog)
 
274
        if self.streamlog:
 
275
            self.removeHandler(self.streamlog)
 
276
            self.streamlog = None
 
277
        if FLAGS.use_stderr:
 
278
            self.streamlog = StreamHandler()
274
279
            self.addHandler(self.streamlog)
275
280
        if FLAGS.publish_errors:
276
281
            self.addHandler(PublishErrorsHandler(ERROR))