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] Periodic Tasks support customize cron logger #459

Closed
yxlimo opened this issue May 10, 2022 · 4 comments
Closed

[FEATURE REQUEST] Periodic Tasks support customize cron logger #459

yxlimo opened this issue May 10, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@yxlimo
Copy link

yxlimo commented May 10, 2022

i want to customize cron logger to get more info, but i can't do it with scheduler

return &Scheduler{
  cron:       cron.New(cron.WithLocation(loc)),
}

maybe we can add an option for schedulerOpts like

struct {
    CronLogger cron.Logger
    Logger Logger
    LogLevel LogLevel
}

or just use asynq logger wrapper, seems little strange, and it need to do many things to handle edge case.

type cronLoggerWrapper struct {
       logger Logger
}

func (l *cronLoggerWrapper) Info(msg string, keysAndValues ...interface{}) {
       l.logger.Info(msg, )
}

WDYT?

@yxlimo yxlimo added the enhancement New feature or request label May 10, 2022
@hibiken
Copy link
Owner

hibiken commented May 10, 2022

@yxlimo Thank you for opening an issue!
What kind of logs do you need?

@yxlimo
Copy link
Author

yxlimo commented May 11, 2022

@yxlimo Thank you for opening an issue! What kind of logs do you need?

thank you for reply,i need logs like this

  • every time cronjob started
  • enqueue task success or failed

@hibiken
Copy link
Owner

hibiken commented May 12, 2022

every time cronjob started

You can do this within your Handler code. If it's shared between multiple task types, I'd recommend using MiddlewareFunc to have that applied to multiple tasks. See this wiki page for examples.

enqueue task success or failed

Currently, you can provide SchedulerOpts.EnqueueErrorHandler but there's an open feature request to add callbacks to both before and after the enqueue event #456; And probably this feature will be available pretty soon

@hibiken
Copy link
Owner

hibiken commented Jun 4, 2022

Closing this since it can be achieved using pre and post enqueue callbacks added in #476

@hibiken hibiken closed this as completed Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants