Example #1
0
func (p *ProcessCounter) Fire(entry *logrus.Entry) error {
	data := make(logrus.Fields, len(entry.Data)+2)
	for k, v := range entry.Data {
		data[k] = v
	}
	data["Counter"] = atomic.AddUint64(&p.counter, 1) - 1
	data["PID"] = os.Getpid()
	entry.Data = data
	return nil
}
Example #2
0
func (f *StenoJSONFormatter) Format(entry *logrus.Entry) ([]byte, error) {
	data := entry.Data
	entry.Data = logrus.Fields{}

	entry.Data["data"] = data
	entry.Data["time"] = time.Now().UTC()
	entry.Data["level"] = entry.Level.String()
	entry.Data["name"] = SERVICE_NAME

	serialized, err := json.Marshal(entry.Data)
	if err != nil {
		return nil, fmt.Errorf("Failed to marchal fields to JSON, %v", err)
	}
	return append(serialized, '\n'), nil
}
Example #3
0
func (l logHook) Fire(entry *logrus.Entry) error {
	entry.Data = logrus.Fields{"plugin": l.id}
	return nil
}