I’m new to Rails and I’m trying to create a custom logger. I’ve placed my custom logger class in app/custom_logger/custom_log.rb
as follows:
module CustomLogger
class CustomLog
def self.info
puts 'called'
end
end
end
In my AccountController
(app/controllers/account_controller.rb
), I’m trying to use this custom logger:
class AccountController < ApplicationController
def get
CustomLogger::CustomLog.info
render status: :ok
end
end
However, when I send a request to this controller, I get the following error:
uninitialized constant AccountController::CustomLogger
I tried adding include CustomLogger
in app/controllers/application_controller.rb
and using require_relative '../custom_logger/custom_log.rb'
, but neither of these approaches worked.