Skip to content

Instantly share code, notes, and snippets.

@zyriuse75
Created April 7, 2014 13:24
Show Gist options
  • Save zyriuse75/ec1ff71df49c1883c6cd to your computer and use it in GitHub Desktop.
Save zyriuse75/ec1ff71df49c1883c6cd to your computer and use it in GitHub Desktop.
module Logging
def logger
@logger ||= Logging.logger_for(self.class.name)
end
# Use a hash class-ivar to cache a unique Logger per class:
@loggers = {}
class << self
def logger_for(classname)
@loggers[classname] ||= configure_logger_for(classname)
end
def configure_logger_for(classname)
logger = Logger.new(STDOUT)
logger.progname = classname
logger
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment