func (hook *DebugLoggerHook) Fire(entry *log.Entry) error {
	_, file, line, ok := runtime.Caller(7)
	if ok == true {
		entry.Message = fmt.Sprintf("%s @ [%s:%d]", entry.Message, file, line)
	}

	return nil
}
Beispiel #2
0
func (p *ExpanderHook) Fire(entry *logrus.Entry) (err error) {
	if v, exist := entry.Data[logrus.ErrorKey]; exist {
		if errCode, ok := v.(errors.ErrCode); ok {
			entry.Data["err_id"] = errCode.Id()
			entry.Data["err_code"] = errCode.Code()
			entry.Data["err_ns"] = errCode.Namespace()
			entry.Data["err_msg"] = errCode.Error()
			entry.Data["err_stack"] = errCode.StackTrace()
			entry.Data["err_ctx"] = errCode.Context().String()

			delete(entry.Data, logrus.ErrorKey)

			entry.Message = errCode.Error()
		}
	}

	return
}
Beispiel #3
0
func (h *AddTraceHook) Fire(entry *logrus.Entry) error {
	entry.Message = h.addTrace(entry.Message)
	return nil
}
Beispiel #4
0
func (l *Logger) fireHook(level logrus.Level, entry logrus.Entry, msg string) {
	entry.Time = time.Now()
	entry.Message = msg
	entry.Level = level
	l.logHooks.Fire(level, &entry)
}
func (hook *ProcessInfoLoggerHook) Fire(entry *log.Entry) error {
	entry.Message = fmt.Sprintf("(pid=%d) %s", os.Getpid(), entry.Message)

	return nil
}
Beispiel #6
0
func (t *intgFmt) Format(e *log.Entry) ([]byte, error) {
	e.Message = strings.Join([]string{"[INTG-TEST]", e.Message}, " ")
	nt := log.TextFormatter{}
	return nt.Format(e)
}