func (hook *Hook) Fire(entry *logrus.Entry) error {
    var (
        Level      uint
        Text       interface{}
        Category   string
        ClassName  string
        MethodName string
        ThreadId   string
    )

    switch entry.Level {
    case logrus.TraceLevel:
        Level = 1
    case logrus.DebugLevel:
        Level = 1
    case logrus.InfoLevel:
        Level = 3
    case logrus.WarnLevel:
        Level = 4
    case logrus.ErrorLevel:
        Level = 5
    case logrus.FatalLevel:
        Level = 6
    case logrus.PanicLevel:
        Level = 6
    }

    if entry.Caller != nil {
        Category, ClassName, MethodName = getCallerInformation(entry.Caller)
    }
    if Value, Exist := entry.Data["Category"]; Exist {
        Category = Value.(string)
        delete(entry.Data, "Category")
    }

    if Value, Exist := entry.Data["ClassName"]; Exist {
        ClassName = Value.(string)
        delete(entry.Data, "ClassName")
    }

    if Value, Exist := entry.Data["MethodName"]; Exist {
        MethodName = Value.(string)
        delete(entry.Data, "MethodName")
    }

    if Value, Exist := entry.Data["ThreadId"]; Exist {
        ThreadId = Value.(string)
        delete(entry.Data, "ThreadId")
    } else {
        ThreadId = ""
    }

    if len(entry.Data) > 0 {
        Text = map[string]interface{}{
            "message": entry.Message,
            "fields":  entry.Data,
        }
    } else {
        Text = entry.Message
    }

    hook.Writer.LogsBuffer = append(
        hook.Writer.LogsBuffer,
        Log{
            float64(entry.Time.Unix()) * 1000.0,
            Level,
            MessageToString(Text),
            Category,
            ClassName,
            MethodName,
            ThreadId,
        },
    )

    if entry.Level == logrus.FatalLevel || entry.Level == logrus.PanicLevel {
        hook.Writer.Flush()
    }

    return nil
}
// Fire send message to Coralogix
Fire send message to Coralogix
// Fire send message to Coralogix
func (hook *Hook) Fire(entry *logrus.Entry) error {
    var (
        Level      uint
        Text       interface{}
        Category   string
        ClassName  string
        MethodName string
        ThreadId   string
    )
    switch entry.Level {
    case logrus.TraceLevel:
        Level = 1
    case logrus.DebugLevel:
        Level = 1
    case logrus.InfoLevel:
        Level = 3
    case logrus.WarnLevel:
        Level = 4
    case logrus.ErrorLevel:
        Level = 5
    case logrus.FatalLevel:
        Level = 6
    case logrus.PanicLevel:
        Level = 6
    }
    if entry.Caller != nil {
        Category, ClassName, MethodName = getCallerInformation(entry.Caller)
    }
    if Value, Exist := entry.Data["Category"]; Exist {
        Category = Value.(string)
        delete(entry.Data, "Category")
    }
    if Value, Exist := entry.Data["ClassName"]; Exist {
        ClassName = Value.(string)
        delete(entry.Data, "ClassName")
    }
    if Value, Exist := entry.Data["MethodName"]; Exist {
        MethodName = Value.(string)
        delete(entry.Data, "MethodName")
    }
    if Value, Exist := entry.Data["ThreadId"]; Exist {
        ThreadId = Value.(string)
        delete(entry.Data, "ThreadId")
    } else {
        ThreadId = ""
    }
    if len(entry.Data) > 0 {
        Text = map[string]interface{}{
            "message": entry.Message,
            "fields":  entry.Data,
        }
    } else {
        Text = entry.Message
    }
    hook.Writer.LogsBuffer = append(
        hook.Writer.LogsBuffer,
        Log{
            float64(entry.Time.Unix()) * 1000.0,
            Level,
            MessageToString(Text),
            Category,
            ClassName,
            MethodName,
            ThreadId,
        },
    )
    if entry.Level == logrus.FatalLevel || entry.Level == logrus.PanicLevel {
        hook.Writer.Flush()
    }
    return nil
}
func ( hook * Hook ) Fire ( entry * logrus . Entry ) error { var ( Level uint Text interface { } Category string ClassName string MethodName string ThreadId string ) switch entry . Level { case logrus . TraceLevel : Level = 1 case logrus . DebugLevel : Level = 1 case logrus . InfoLevel : Level = 3 case logrus . WarnLevel : Level = 4 case logrus . ErrorLevel : Level = 5 case logrus . FatalLevel : Level = 6 case logrus . PanicLevel : Level = 6 } if entry . Caller != nil { Category , ClassName , MethodName = getCallerInformation ( entry . Caller ) } if Value , Exist := entry . Data [ " " ] ; Exist { Category = Value . ( string ) delete ( entry . Data , " " ) } if Value , Exist := entry . Data [ " " ] ; Exist { ClassName = Value . ( string ) delete ( entry . Data , " " ) } if Value , Exist := entry . Data [ " " ] ; Exist { MethodName = Value . ( string ) delete ( entry . Data , " " ) } if Value , Exist := entry . Data [ " " ] ; Exist { ThreadId = Value . ( string ) delete ( entry . Data , " " ) } else { ThreadId = " " } if len ( entry . Data ) > 0 { Text = map [ string ] interface { } { " " : entry . Message , " " : entry . Data , } } else { Text = entry . Message } hook . Writer . LogsBuffer = append ( hook . Writer . LogsBuffer , Log { float64 ( entry . Time . Unix ( ) ) * 1000.0 , Level , MessageToString ( Text ) , Category , ClassName , MethodName , ThreadId , } , ) if entry . Level == logrus . FatalLevel || entry . Level == logrus . PanicLevel { hook . Writer . Flush ( ) } return nil }
Fire send message to Coralogix
Fire send message to Coralogix