Пример #1
0
func (hook *SyslogHookNoFrozen) Fire(entry *log.Entry) error {
	select {
	case hook.logCh <- entry:
	default:
		skippedNew := atomic.AddUint64(&hook.skipped, uint64(1))
		log.WithoutHooks().Errorf("syslog entry %v skipped (total %d)", entry, skippedNew)
	}
	return nil
}
Пример #2
0
func (hook *SyslogHookNoFrozen) serve() {
	for {
		select {
		case entry := <-hook.logCh:
			err := hook.syslogHook.Fire(entry)
			if err != nil {
				log.WithoutHooks().Errorf("syslog error: %v", err)
			}
		case <-hook.exitCh:
			return
		}
	}
}