I am using the SemanticLogger for logging. It provides a Loggable module that classes can include to create logger class and instance methods that return a class-specific logger object.
I am working with a module in my own code base that requires access to a logger method in its instance methods. If I call include SemanticLogger::Loggable in the module, it makes a logger method accessible to module "class" methods, but not instance methods, since modules don't have instances and the module instance methods become methods of the including class.
So for the logger call not to fail, I need to ensure that any class that includes my module also includes SemanticLogger::Loggable. What's the best way to deal with this? Maybe this?:
module MyModule
# ...
def included(_includer_module_or_class)
require 'semantic_logger'
include SemanticLogger::Loggable
end
...
end