You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
I'm using exception logger in classes that are not within a controller context. This is the case for example for resque workers.
Resque workers are classes with a class method named perform in order to perform background jobs. For logging an exception I need a class method that logs exceptions. I include this module to all my workers:
moduleWorkerExceptionLoggerdefself.included(target)target.extend(ClassMethods)endmoduleClassMethodsdeflog_exception(exception,data=nil)message=exception.message.inspectmessage << "\n* Extra Data\n\n#{data}"unlessdata.blank?ExceptionLogger::LoggedException.create! \
:exception_class=>exception.class.name,:controller_name=>self.to_s,:action_name=>caller_locations(1,1)[0].label,:message=>message,:backtrace=>exception.backtraceendend
This method sets "controller_name" to the name of the class and "action_name" to the name of the calling function.
It would be cool to have this functionallity directly in the gem:
class method for logging an exception
universal create_from_exception (i.e. that not only works with conrollers)
I'm using exception logger in classes that are not within a controller context. This is the case for example for resque workers.
Resque workers are classes with a class method named perform in order to perform background jobs. For logging an exception I need a class method that logs exceptions. I include this module to all my workers:
This method sets "controller_name" to the name of the class and "action_name" to the name of the calling function.
It would be cool to have this functionallity directly in the gem: