Open aymanbagabas opened 1 year ago
i think you can save it to database,this is only the basic info in memory.
My issue is the logger, I want to be able to add context to the logs for a job.
My issue is the logger, I want to be able to add context to the logs for a job.
when i use it ,i argee with you ,i want to log when the job is start and end.like this
func LogTime(log cron.Logger) cron.JobWrapper {
return func(j cron.Job) cron.Job {
return cron.FuncJob(func() {
start := time.Now()
defer func(s time.Time) {
log.Info("this job start at: %s, end at %s\n", start, time.Now())
}(start)
j.Run()
})
}
}
but don't know which job running
My issue is the logger, I want to be able to add context to the logs for a job.
when i use it ,i argee with you ,i want to log when the job is start and end.like this
func LogTime(log cron.Logger) cron.JobWrapper { return func(j cron.Job) cron.Job { return cron.FuncJob(func() { start := time.Now() defer func(s time.Time) { log.Info("this job start at: %s, end at %s\n", start, time.Now()) }(start) j.Run() }) } }
but don't know which job running
oh,i made a mistake,it can't calc the time , when run it use goroutine.
-< /
I would like to have some sort of a description of jobs added to the scheduler so that when it logs any entry, it logs the job's description along with the rest of the props.
Instead of
AddFunc(spec string, cmd func())
useAddFunc(desc, spec string, cmd func())
to add more context to jobs.