Example #1
0
func (n *nativeLogger) Send(p level.Priority, m message.Composer) {
	if !GetMessageInfo(n.level, p, m).ShouldLog() {
		return
	}

	n.logger.Printf(n.template, p, m.Resolve())
}
Example #2
0
func (f *fileLogger) Send(p level.Priority, m message.Composer) {
	if !GetMessageInfo(f.level, p, m).ShouldLog() {
		return
	}

	f.logger.Printf(f.template, int(p), m.Resolve())
}
Example #3
0
func (s *InternalSender) Send(p level.Priority, m message.Composer) {
	o := &InternalMessage{
		Message:  m,
		Priority: p,
		Rendered: m.Resolve(),
		Logged:   GetMessageInfo(s.level, p, m).ShouldLog(),
	}

	s.output <- o
}
Example #4
0
// For sending logging messages, in most cases, use the
// Journaler.sender.Send() method, but we have a couple of methods to
// use for the Panic/Fatal helpers.
func (g *Grip) sendPanic(priority level.Priority, m message.Composer) {
	// the Send method in the Sender interface will perform this
	// check but to add fatal methods we need to do this here.
	if !send.GetMessageInfo(g.getLevelInfo(), priority, m).ShouldLog() {
		return
	}

	g.sender.Send(priority, m)
	panic(m.Resolve())
}
Example #5
0
func (s *systemdJournal) Send(p level.Priority, m message.Composer) {
	if !GetMessageInfo(s.level, p, m).ShouldLog() {
		return
	}

	msg := m.Resolve()
	err := journal.Send(msg, s.convertPrioritySystemd(p), s.options)
	if err != nil {
		s.fallback.Println("systemd journaling error:", err.Error())
		s.fallback.Printf("[p=%s]: %s\n", p, msg)
	}
}
Example #6
0
// GetMessageInfo takes the sender's configured LevelInfo, a priority
// for the message, and a MessageComposer object and returns a
// MessageInfo.
func GetMessageInfo(info LevelInfo, level level.Priority, m message.Composer) MessageInfo {
	return MessageInfo{
		loggable:       m.Loggable(),
		aboveThreshold: level <= info.thresholdLevel,
	}
}