add logrotate support for MinIO logs (#19641)

This commit is contained in:
Harshavardhana
2024-05-01 10:57:52 -07:00
committed by GitHub
parent dbfb5e797b
commit 8c1bba681b
11 changed files with 259 additions and 43 deletions
+10 -12
View File
@@ -25,7 +25,6 @@ import (
"time"
"github.com/minio/minio/internal/color"
c "github.com/minio/pkg/v2/console"
"github.com/minio/pkg/v2/logger/message/log"
)
@@ -99,8 +98,7 @@ func (f fatalMsg) json(msg string, args ...interface{}) {
if err != nil {
panic(err)
}
fmt.Println(string(logJSON))
fmt.Fprintln(Output, string(logJSON))
ExitFunc(1)
}
@@ -139,16 +137,16 @@ func (f fatalMsg) pretty(msg string, args ...interface{}) {
ansiSaveAttributes()
// Print banner with or without the log tag
if !tagPrinted {
c.Print(logBanner)
fmt.Fprint(Output, logBanner)
tagPrinted = true
} else {
c.Print(emptyBanner)
fmt.Fprint(Output, emptyBanner)
}
// Restore the text color of the error message
ansiRestoreAttributes()
ansiMoveRight(bannerWidth)
// Continue error message printing
c.Println(line)
fmt.Fprintln(Output, line)
break
}
}
@@ -176,7 +174,7 @@ func (i infoMsg) json(msg string, args ...interface{}) {
if err != nil {
panic(err)
}
fmt.Println(string(logJSON))
fmt.Fprintln(Output, string(logJSON))
}
func (i infoMsg) quiet(msg string, args ...interface{}) {
@@ -184,9 +182,9 @@ func (i infoMsg) quiet(msg string, args ...interface{}) {
func (i infoMsg) pretty(msg string, args ...interface{}) {
if msg == "" {
c.Println(args...)
fmt.Fprintln(Output, args...)
}
c.Printf(msg, args...)
fmt.Fprintf(Output, msg, args...)
}
type errorMsg struct{}
@@ -209,7 +207,7 @@ func (i errorMsg) json(msg string, args ...interface{}) {
if err != nil {
panic(err)
}
fmt.Println(string(logJSON))
fmt.Fprintln(Output, string(logJSON))
}
func (i errorMsg) quiet(msg string, args ...interface{}) {
@@ -218,9 +216,9 @@ func (i errorMsg) quiet(msg string, args ...interface{}) {
func (i errorMsg) pretty(msg string, args ...interface{}) {
if msg == "" {
c.Println(args...)
fmt.Fprintln(Output, args...)
}
c.Printf(msg, args...)
fmt.Fprintf(Output, msg, args...)
}
// Error :