I have set up my logger using a module with the following (simplified) version:
module Logging
class << self
def logger
end
def logger=(logger)
@logger = logger
end
end
end
I would like to do something like the following (it didn't work):
Get the name of the currently executing method
def test_method
return __callee__
end
This way without the above, add logger.progname = self.test_method
So it should look like this:
module Logging
class << self
def logger
return @logger if @logger
@logger.progname = self.test_method
end
def logger=(logger)
@logger = logger
end
end
end
The end goal should be such that, with method "MyMethod":
def my_method
logger.debug "hi"
end
I get => "my_method: "hi"