Exemple #1
0
// SetLogFileConfig sets the log file config to be used globally.
func SetLogFileConfig(lfc *LogFileConfig) error {
	globalLock.Lock()
	defer globalLock.Unlock()

	first := true
	var w = currentLogFileWriter
	if w != nil {
		first = false
		w.lock.Lock()
		defer w.lock.Unlock()
		w.Close()
	} else {
		w = &logFileWriter{}
	}
	w.config = *lfc

	err := w.Open(time.Now())
	if err != nil {
		return err
	}

	if first {
		fileBackend := logging.NewLogBackend(w, "", 0)
		logging.SetBackend(fileBackend)

		stderrIsTerminal = false
		currentLogFileWriter = w
	}
	return nil
}
Exemple #2
0
func (log *Standard) initLogging() {
	// Logging is always done to stderr. It's the responsibility of the
	// launcher (like launchd on OSX, or the autoforking code) to set up stderr
	// to point to the appropriate log file.
	initLoggingBackendOnce.Do(func() {
		logBackend := logging.NewLogBackend(os.Stderr, "", 0)
		logging.SetBackend(logBackend)
		logging.SetLevel(logging.INFO, log.module)
	})
}
Exemple #3
0
func (log *Standard) initLogging(iow io.Writer) {
	// Logging is always done to the given io.Writer. It's the
	// responsibility of the launcher (like launchd on OSX, or the
	// autoforking code) to set it up to point to the appropriate
	// log file.
	initLoggingBackendOnce.Do(func() {
		logBackend := logging.NewLogBackend(iow, "", 0)
		logging.SetBackend(logBackend)
	})

	initLoggingSetLevelMutex.Lock()
	defer initLoggingSetLevelMutex.Unlock()
	if initLoggingSetLevelCalled == nil {
		initLoggingSetLevelCalled = make(map[string]bool)
	}
	if !initLoggingSetLevelCalled[log.module] {
		logging.SetLevel(logging.INFO, log.module)
		initLoggingSetLevelCalled[log.module] = true
	}
}
Exemple #4
0
func init() {
	logBackend := logging.NewLogBackend(ErrorWriter(), "", 0)
	logging.SetBackend(logBackend)
}