Beispiel #1
0
func (l *LineParser) makeEvent(v map[string]interface{}) *message.Event {
	if l.rkey != "" && l.rparser != nil {
		if s, ok := v[l.rkey].(string); ok {
			if record, err := l.rparser.Parse(s); err == nil {
				v = record
			} else {
				l.env.Log.Warningf("Record parser failed: %v", err)
			}
		} else {
			l.env.Log.Warning("Record key configured, but not exists")
		}
	}
	if l.timeKey != "" && l.timeParser != nil {
		if val, ok := v[l.timeKey]; ok {
			t, err := l.timeParser.Parse(val)
			if err == nil {
				return message.NewEventWithTime(l.tag, t, v)
			}
			l.env.Log.Warningf("Time parser failed: %v", err)
		} else {
			l.env.Log.Warning("Time key configured, but not exists")
		}
	}
	return message.NewEvent(l.tag, v)
}
Beispiel #2
0
func (l *Logger) emit(lv level, msg string) {
	lvStr := lv.String()
	v := map[string]interface{}{
		"name":    l.Name,
		"host":    hostname,
		"level":   lvStr,
		"message": l.Prefix + msg,
	}
	l.EmitFunc(message.NewEvent("fluxion.log."+lvStr, v))
}