实现节点运行日志上传

This commit is contained in:
刘祥超
2020-10-09 11:06:43 +08:00
parent 04b9a65d4d
commit 458187acd2
16 changed files with 184 additions and 63 deletions

View File

@@ -6,9 +6,9 @@ import (
"compress/gzip"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeNode/internal/caches"
"github.com/TeaOSLab/EdgeNode/internal/logs"
"github.com/TeaOSLab/EdgeNode/internal/utils"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/logs"
"net"
"net/http"
"strings"
@@ -115,7 +115,7 @@ func (this *HTTPWriter) Write(data []byte) (n int, err error) {
if err != nil {
_ = this.cacheWriter.Discard()
this.cacheWriter = nil
logs.Println("write cache failed: " + err.Error())
logs.Error("REQUEST_WRITER", "write cache failed: "+err.Error())
}
}
} else {
@@ -127,7 +127,7 @@ func (this *HTTPWriter) Write(data []byte) (n int, err error) {
if this.gzipBodyWriter != nil {
_, err := this.gzipBodyWriter.Write(data)
if err != nil {
logs.Error(err)
logs.Error("REQUEST_WRITER", err.Error())
}
} else {
this.body = append(this.body, data...)
@@ -281,7 +281,7 @@ func (this *HTTPWriter) prepareGzip(size int64) {
var err error = nil
this.gzipWriter, err = gzip.NewWriterLevel(this.writer, int(this.gzipConfig.Level))
if err != nil {
logs.Error(err)
logs.Error("REQUEST_WRITER", err.Error())
return
}
@@ -290,7 +290,7 @@ func (this *HTTPWriter) prepareGzip(size int64) {
this.gzipBodyBuffer = bytes.NewBuffer([]byte{})
this.gzipBodyWriter, err = gzip.NewWriterLevel(this.gzipBodyBuffer, int(this.gzipConfig.Level))
if err != nil {
logs.Error(err)
logs.Error("REQUEST_WRITER", err.Error())
}
}
@@ -357,7 +357,7 @@ func (this *HTTPWriter) prepareCache(size int64) {
expiredAt := utils.UnixTime() + life
cacheWriter, err := storage.Open(this.req.cacheKey, expiredAt)
if err != nil {
logs.Println("write cache failed: " + err.Error())
logs.Error("REQUEST_WRITER", "write cache failed: "+err.Error())
return
}
this.cacheWriter = cacheWriter
@@ -369,7 +369,7 @@ func (this *HTTPWriter) prepareCache(size int64) {
headerData := this.HeaderData()
_, err = cacheWriter.Write(headerData)
if err != nil {
logs.Println("write cache failed: " + err.Error())
logs.Error("REQUEST_WRITER", "write cache failed: "+err.Error())
_ = this.cacheWriter.Discard()
this.cacheWriter = nil
return