From 86b6afe0b4bdf2ac6b69ffe313e7af716880af35 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:59:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201Panel=20=E6=97=A5=E5=BF=97=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=96=E6=B6=88=E5=8E=8B=E7=BC=A9=20(#2672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/log/writer.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/backend/log/writer.go b/backend/log/writer.go index 979c31d77..74d7a1959 100644 --- a/backend/log/writer.go +++ b/backend/log/writer.go @@ -12,7 +12,6 @@ import ( "unsafe" "github.com/1Panel-dev/1Panel/backend/global" - "github.com/1Panel-dev/1Panel/backend/utils/files" ) type Writer struct { @@ -120,7 +119,7 @@ func NewWriterFromConfig(c *Config) (RollingWriter, error) { } fileName := c.FileName - if strings.Contains(fi.Name(), fileName) && strings.Contains(fi.Name(), c.LogSuffix+".gz") { + if strings.Contains(fi.Name(), fileName) && strings.Contains(fi.Name(), c.LogSuffix) { start := strings.Index(fi.Name(), "-") end := strings.Index(fi.Name(), c.LogSuffix) name := fi.Name() @@ -237,11 +236,6 @@ func (w *Writer) Reopen(file string) error { w.file = newFile go func() { - if err := w.CompressFile(file); err != nil { - log.Println("error in compress log file", err) - return - } - if w.cf.MaxRemain > 0 { retry: select { @@ -254,17 +248,3 @@ func (w *Writer) Reopen(file string) error { }() return nil } - -func (w *Writer) CompressFile(logFile string) error { - op := files.NewFileOp() - comFileName := path.Base(logFile) + ".gz" - filePath := path.Dir(logFile) - - if err := op.Compress([]string{logFile}, filePath, comFileName, files.Gz); err != nil { - return err - } - if errR := os.Remove(logFile); errR != nil { - return errR - } - return nil -}