Sha256: 8dbce3600ff6b17502c9e5cb884e4539b3a32558c599ded40d81520c312f89d2
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require 'tee_logger/version' require 'tee_logger/constants' require 'tee_logger/utils' require 'tee_logger/tee_logger_base' require 'logger' # namespace module TeeLogger # shortcut for TeeLogger::TeeLoggerBase.new # @param logdev [String] # @param shift_age [Integer] # @param shift_size [Integer] # @return [TeeLogger::TeeLoggerBase] # @see TeeLoggerBase def self.new(logdev = DEFAULT_FILE, shift_age = 0, shift_size = 1_048_576) TeeLoggerBase.new(logdev, shift_age, shift_size) end @logdev = nil # @return [String, File] instance variable @logdev. def self.logdev @logdev end # set TeeLogger's class instance variable @logdev. # extend or include TeeLogger then, @logdev is default argument # for Logger.new(logdev). # @param logdev [String, File] def self.logdev=(logdev) @logdev = logdev end # define singleton method .logger for your module. # and TeeLogger.progname is your module name. def self.extended(mod) mod.define_singleton_method(:logger) do return @logger if @logger @logger = TeeLoggerBase.new(TeeLogger.logdev || DEFAULT_FILE) @logger.progname = mod @logger 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 return @logger if @logger @logger = TeeLoggerBase.new(TeeLogger.logdev || DEFAULT_FILE) @logger.progname = klass.name @logger end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tee_logger-3.2.0 | lib/tee_logger.rb |