feat: gc removes logrus (#1548)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
ff29d150e0
commit
439ad71230
2
go.mod
2
go.mod
|
|
@ -51,7 +51,6 @@ require (
|
||||||
github.com/schollz/progressbar/v3 v3.8.7
|
github.com/schollz/progressbar/v3 v3.8.7
|
||||||
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b
|
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b
|
||||||
github.com/shirou/gopsutil/v3 v3.22.7
|
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/cobra v1.5.0
|
||||||
github.com/spf13/viper v1.12.0
|
github.com/spf13/viper v1.12.0
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
|
|
@ -178,6 +177,7 @@ require (
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/rs/cors v1.8.2 // indirect
|
github.com/rs/cors v1.8.2 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // 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/afero v1.8.2 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func (m *MachineryLogger) Panicf(format string, args ...any) {
|
||||||
logger.JobLogger.Panic(args...)
|
logger.JobLogger.Panic(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panicln sends to logrus.Panic
|
// Panicln sends to logger.Panic
|
||||||
func (m *MachineryLogger) Panicln(args ...any) {
|
func (m *MachineryLogger) Panicln(args ...any) {
|
||||||
logger.JobLogger.Panic(args...)
|
logger.JobLogger.Panic(args...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GC is the interface used for release resource.
|
// GC is the interface used for release resource.
|
||||||
|
|
@ -65,7 +63,7 @@ func WithLogger(logger Logger) Option {
|
||||||
func New(options ...Option) GC {
|
func New(options ...Option) GC {
|
||||||
g := &gc{
|
g := &gc{
|
||||||
tasks: &sync.Map{},
|
tasks: &sync.Map{},
|
||||||
logger: logrus.New(),
|
logger: &gcLogger{},
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
package gc
|
package gc
|
||||||
|
|
||||||
|
import (
|
||||||
|
logger "d7y.io/dragonfly/v2/internal/dflog"
|
||||||
|
)
|
||||||
|
|
||||||
// Logger is the interface used in GC for logging.
|
// Logger is the interface used in GC for logging.
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
// Infof logs routine messages for GC.
|
// Infof logs routine messages for GC.
|
||||||
|
|
@ -25,3 +29,16 @@ type Logger interface {
|
||||||
// Error logs error messages for GC.
|
// Error logs error messages for GC.
|
||||||
Errorf(template string, args ...any)
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue