-
Notifications
You must be signed in to change notification settings - Fork 12
Logging hooks #32
Description
suggestion / question
We've started using the slack-bot-server in our product and really like what it does. One improvement I wanted to make was to have it log unhandled exceptions to an error logging component or service of choice, and being able to configure that. At the moment, the only thing the server does is writing errors to the log.
To workaround, I monkey patched the log_error method like below.
module SlackBotServer::Logging
def log_error(e, *args)
message = "#{e} - #{e.message}"
message += " (#{log_string(*args)})" if args.any?
# note I changes the log levels from the defaults here as well.
SlackBotServer.logger.error("#{message}")
SlackBotServer.logger.debug(e.backtrace.join("\n"))
# do custom error reporting/handling here.
Rollbar.error(e, message)
end
endI went this route after looking at extending the gem sources in a way to make this less of a patch. But I didn't get to a solution that I felt good enough to submit a pull request.
Alternatives I tried were along the same line as what the gem does today in allowing you to override the SlackBotServer.logger or how you allow on_add and other hooks.
Has this been considered? Suggestions?
Based on feedback I'll be happy to work on what I started some more and submit a PR.