Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add cron job description to entry #485

Open
aymanbagabas opened this issue Apr 2, 2023 · 4 comments
Open

Feature request: add cron job description to entry #485

aymanbagabas opened this issue Apr 2, 2023 · 4 comments

Comments

@aymanbagabas
Copy link

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()) use AddFunc(desc, spec string, cmd func()) to add more context to jobs.

@blight19
Copy link

blight19 commented Apr 7, 2023

i think you can save it to database,this is only the basic info in memory.

@aymanbagabas
Copy link
Author

My issue is the logger, I want to be able to add context to the logs for a job.

@blight19
Copy link

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

@blight19
Copy link

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.

-<
/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants