feat: use cron name to log error
ndeitch opened this issue · 4 comments
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
Improve unhandled exceptions inside cron tasks.
Describe the solution you'd like
Use cron name if provided as context for log.error message.
Update:
schedule/lib/schedule.explorer.ts
Line 125 in 73f46ad
from: this.logger.error(error)
to: this.logger.error(error, cronName)
cronName would be add as param for wrapFunctionInTryCatchBlocks
existing method, it can be null if so, use Scheduler
as default
Teachability, documentation, adoption, migration strategy
Not sure about add any tip about this in doc.
What is the motivation / use case for changing the behavior?
Currently when unexpected errors happens only error message is print without much context about where it came from, in big repos with many cron jobs it's hard to find which method thrown the error.
I'm able to implement this PR and understand that it can be considered unnecessary as exceptions should be handled inside each cron.
if we implement this, we should change the following somehow
schedule/lib/schedule.explorer.ts
Lines 9 to 10 in 73f46ad
so every log entry will have the cron name instead
What do you suggest @micalevisk? Should I open a PR and we discuss about the implementation?
yep, feel free to implement this
Feel free to create a PR for this.