I want to be able to log things to my Rail's app logs from a ruby class.
I was hoping to do logger.info "some stuff"
from a class in my_app/app/myClass.rb
, but it's not defined. When I use logger
in my controllers and elsewhere it works.
I'm a bit new to Rails / Ruby, and I'm assuming this is simply because the logger
class isn't included in myClass.rb
, but it is automatically included in all controllers, models, etc.
How can I include the logger
class in an arbitrary ruby class, or otherwise log to my rails app from a ruby class?
(Added tag for "Pundit" since specifically I am using logger in a Pundit policy file, but it's just a ruby class :P)