core/writeLog.go

33 lines
611 B
Go
Raw Normal View History

package core
import (
"bytes"
2025-01-15 00:36:49 +08:00
// "fmt"
"net/http"
"os"
logrus "github.com/sirupsen/logrus"
)
type WriteLog struct {
Content []byte
Tag string
Id string
}
func (wg *WriteLog) Process(cr *Core) error {
go func() {
reqBody := bytes.NewBuffer(wg.Content)
cr.Env = os.Getenv("GO_ENV")
cr.FluentBitUrl = os.Getenv("TEXUS_FluentBitUrl")
fullUrl := "http://" + cr.FluentBitUrl + "/" + wg.Tag
res, err := http.Post(fullUrl, "application/json", reqBody)
2025-01-14 22:14:06 +08:00
logrus.Warn("requested, response:", fullUrl, string(wg.Content), res)
if err != nil {
logrus.Error(err)
}
}()
return nil
}