feat: logx with color (#1872)

* feat: logx with color

* chore: update logs

* fix test error

* chore: change colors of http codes

* chore: add comments

* chore: use faith/color instead of ascii code color

* chore: update colors

* chore: update colors

* chore: fix duplicated slowcall text

* chore: remove slowcall colors
This commit is contained in:
Kevin Wan
2022-05-07 23:22:39 +08:00
committed by GitHub
parent 5383e29ce6
commit 69c2bad410
13 changed files with 261 additions and 26 deletions

View File

@@ -210,6 +210,12 @@ func (l *RotateLogger) maybeCompressFile(file string) {
ErrorStack(r)
}
}()
if _, err := os.Stat(file); err != nil {
// file not exists or other error, ignore compression
return
}
compressLogFile(file)
}
@@ -292,7 +298,7 @@ func compressLogFile(file string) {
start := time.Now()
Infof("compressing log file: %s", file)
if err := gzipFile(file); err != nil {
ErrorStackf("compress error: %s", err)
Errorf("compress error: %s", err)
} else {
Infof("compressed log file: %s, took %s", file, time.Since(start))
}