lib/tee_logger.rb in tee_logger-3.0.3 vs lib/tee_logger.rb in tee_logger-3.1.0
- old
+ new
@@ -9,9 +9,35 @@
# @see TeeLogger
def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576)
TeeLogger.new(logdev, shift_age, shift_size)
end
+ # define singleton method .logger for your module.
+ # and TeeLogger.progname is your module name.
+ def self.extended(mod)
+ mod.class_eval do
+ define_singleton_method(:logger) do |logdev = DEFAULT_FILE|
+ return @logger if @logger
+ @logger = TeeLogger.new(logdev)
+ @logger.progname = self
+ @logger
+ end
+ end
+ end
+
+ # define instance method #logger for your class.
+ # and TeeLogger.progname is your class name.
+ def self.included(klass)
+ klass.class_eval do
+ define_method(:logger) do |logdev = DEFAULT_FILE|
+ return @logger if @logger
+ @logger = TeeLogger.new(logdev)
+ @logger.progname = self.class.name
+ @logger
+ end
+ end
+ end
+
# main
# @see http://www.rubydoc.info/stdlib/logger/Logger Logger
class TeeLogger
class << self
# @!macro [attach] logging_methods