feat: gc removes logrus (#1548)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2022-08-09 14:34:32 +08:00
parent ff29d150e0
commit 439ad71230
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
4 changed files with 20 additions and 5 deletions

2
go.mod
View File

@ -51,7 +51,6 @@ require (
github.com/schollz/progressbar/v3 v3.8.7
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b
github.com/shirou/gopsutil/v3 v3.22.7
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.0
@ -178,6 +177,7 @@ require (
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect

View File

@ -46,7 +46,7 @@ func (m *MachineryLogger) Panicf(format string, args ...any) {
logger.JobLogger.Panic(args...)
}
// Panicln sends to logrus.Panic
// Panicln sends to logger.Panic
func (m *MachineryLogger) Panicln(args ...any) {
logger.JobLogger.Panic(args...)
}

View File

@ -22,8 +22,6 @@ import (
"fmt"
"sync"
"time"
"github.com/sirupsen/logrus"
)
// GC is the interface used for release resource.
@ -65,7 +63,7 @@ func WithLogger(logger Logger) Option {
func New(options ...Option) GC {
g := &gc{
tasks: &sync.Map{},
logger: logrus.New(),
logger: &gcLogger{},
done: make(chan bool),
}

View File

@ -18,6 +18,10 @@
package gc
import (
logger "d7y.io/dragonfly/v2/internal/dflog"
)
// Logger is the interface used in GC for logging.
type Logger interface {
// Infof logs routine messages for GC.
@ -25,3 +29,16 @@ type Logger interface {
// Error logs error messages for GC.
Errorf(template string, args ...any)
}
// gcLogger is default logger of dflog.
type gcLogger struct{}
// Infof logs routine messages for GC.
func (gl *gcLogger) Infof(template string, args ...any) {
logger.CoreLogger.Infof(template, args)
}
// Error logs error messages for GC.
func (gl *gcLogger) Errorf(template string, args ...any) {
logger.CoreLogger.Errorf(template, args)
}