mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
- 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.
37 lines
790 B
Go
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"),
|
|
}
|
|
}
|