Module: EasyLogging
- Defined in:
- lib/easy_logging.rb,
lib/easy_logging/version.rb
Defined Under Namespace
Modules: Initializer
Constant Summary collapse
- VERSION =
"0.4.0"
Class Attribute Summary collapse
-
.formatter ⇒ Object
Returns the value of attribute formatter.
-
.level ⇒ Object
Returns the value of attribute level.
-
.log_destination ⇒ Object
Returns the value of attribute log_destination.
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.
Class Attribute Details
.formatter ⇒ Object
Returns the value of attribute formatter.
15 16 17 |
# File 'lib/easy_logging.rb', line 15 def formatter @formatter end |
.level ⇒ Object
Returns the value of attribute level.
15 16 17 |
# File 'lib/easy_logging.rb', line 15 def level @level end |
.log_destination ⇒ Object
Returns the value of attribute log_destination.
15 16 17 |
# File 'lib/easy_logging.rb', line 15 def log_destination @log_destination end |
Class Method Details
.configure_logger_for(classname) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/easy_logging.rb', line 51 def self.configure_logger_for(classname) logger = Logger.new(log_destination) logger.level = level logger.progname = classname logger.formatter = formatter unless formatter.nil? logger end |
.included(base) ⇒ Object
Executed when the module is included. See: stackoverflow.com/a/5160822/2771889
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/easy_logging.rb', line 32 def self.included(base) base.send :prepend, Initializer # Class level private logger method for includer class (base) class << base private def logger @logger ||= EasyLogging.logger_for(self) end end # Initialize class level logger at the time of including base.send (:logger) end |
.logger_for(classname) ⇒ Object
Global, memoized, lazy initialized instance of a logger
47 48 49 |
# File 'lib/easy_logging.rb', line 47 def self.logger_for(classname) @loggers[classname] ||= configure_logger_for(classname) end |