Module: EasyLogging
- Defined in:
- lib/easy_logging.rb,
lib/easy_logging/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
- .configure_logger_for(classname) ⇒ Object
-
.included(base) ⇒ Object
Executed when the module is included.
-
.logger_for(classname) ⇒ Object
Global, memoized, lazy initialized instance of a logger.
Instance Method Summary collapse
Class Method Details
.configure_logger_for(classname) ⇒ Object
26 27 28 29 30 |
# File 'lib/easy_logging.rb', line 26 def self.configure_logger_for(classname) logger = Logger.new(STDOUT) logger.progname = classname logger end |
.included(base) ⇒ Object
Executed when the module is included. See: stackoverflow.com/a/5160822/2771889
14 15 16 17 18 19 |
# File 'lib/easy_logging.rb', line 14 def self.included(base) # Class level logger method for includer class (base) def base.logger @logger ||= EasyLogging.logger_for(self) end end |
.logger_for(classname) ⇒ Object
Global, memoized, lazy initialized instance of a logger
22 23 24 |
# File 'lib/easy_logging.rb', line 22 def self.logger_for(classname) @loggers[classname] ||= configure_logger_for(classname) end |
Instance Method Details
#logger ⇒ Object
9 10 11 |
# File 'lib/easy_logging.rb', line 9 def logger @logger ||= EasyLogging.logger_for(self.class.name) end |