mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-02 20:08:03 +08:00
fix: 修改log文件的压缩格式
This commit is contained in:
parent
67aaa3b2bd
commit
c05d669c5f
@ -16,7 +16,7 @@ import (
|
||||
|
||||
const (
|
||||
TimeFormat = "2006-01-02 15:04:05"
|
||||
FileTImeFormat = "2006-01-02-15-04-05"
|
||||
FileTImeFormat = "2006-01-02"
|
||||
RollingTimePattern = "0 0 * * *"
|
||||
)
|
||||
|
||||
@ -28,7 +28,6 @@ func Init() {
|
||||
}
|
||||
|
||||
func setOutput(logger *logrus.Logger, config configs.LogConfig) {
|
||||
|
||||
writer, err := log.NewWriterFromConfig(&log.Config{
|
||||
LogPath: config.Path,
|
||||
FileName: config.LogName,
|
||||
|
@ -120,7 +120,7 @@ func NewWriterFromConfig(c *Config) (RollingWriter, error) {
|
||||
}
|
||||
|
||||
fileName := c.FileName
|
||||
if strings.Contains(fi.Name(), fileName) && strings.Contains(fi.Name(), c.LogSuffix+".tar.gz") {
|
||||
if strings.Contains(fi.Name(), fileName) && strings.Contains(fi.Name(), c.LogSuffix+".gz") {
|
||||
start := strings.Index(fi.Name(), "-")
|
||||
end := strings.Index(fi.Name(), c.LogSuffix)
|
||||
name := fi.Name()
|
||||
@ -259,11 +259,11 @@ func (w *Writer) Reopen(file string) error {
|
||||
|
||||
func (w *Writer) CompressFile(logFile string) error {
|
||||
op := files.NewFileOp()
|
||||
comFileName := path.Base(logFile) + ".tar.gz"
|
||||
comFileName := path.Base(logFile) + ".gz"
|
||||
filePath := path.Dir(logFile)
|
||||
|
||||
fmt.Println(path.Dir(logFile))
|
||||
if err := op.Compress([]string{logFile}, filePath, comFileName, files.TarGz); err != nil {
|
||||
if err := op.Compress([]string{logFile}, filePath, comFileName, files.Gz); err != nil {
|
||||
return err
|
||||
}
|
||||
if errR := os.Remove(logFile); errR != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user