Files
crawlab/core/schedule/logger.go
Marvin Zhang dc59599509 refactor: remove db module and update imports to core/mongo
- Deleted the db module, consolidating database-related functionality into the core/mongo package for better organization and maintainability.
- Updated all import paths across the codebase to replace references to the removed db module with core/mongo.
- Cleaned up unused code and dependencies, enhancing overall project clarity and reducing complexity.
- This refactor improves the structure of the codebase by centralizing database operations and simplifying module management.
2024-12-25 10:28:21 +08:00

37 lines
790 B
Go

package schedule
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/robfig/cron/v3"
"strings"
)
type CronLogger struct {
interfaces.Logger
}
func (l *CronLogger) Info(msg string, keysAndValues ...interface{}) {
p := l.getPlaceholder(len(keysAndValues))
l.Infof("cron: %s %s", msg, p)
}
func (l *CronLogger) Error(err error, msg string, keysAndValues ...interface{}) {
p := l.getPlaceholder(len(keysAndValues))
l.Errorf("cron: %s %v %s", msg, err, p)
}
func (l *CronLogger) getPlaceholder(n int) (s string) {
var arr []string
for i := 0; i < n; i++ {
arr = append(arr, "%v")
}
return strings.Join(arr, " ")
}
func NewCronLogger() cron.Logger {
return &CronLogger{
Logger: utils.NewLogger("Cron"),
}
}