README.md in tee_logger-3.2.0 vs README.md in tee_logger-3.2.1

- old
+ new

@@ -45,105 +45,161 @@ ``` ## Usage +### let's logging ```ruby - require 'tee_logger' +require 'tee_logger' - # Logger.new like options(logdev, shift_age, shift_size) - # options default value is - # logdev = './tee_logger.log' - # shift_age = 0 - # shift_size = 1_048_576 - tl = TeeLogger.new +# Logger.new like options(logdev, shift_age, shift_size) +# options default value is +# logdev = './tee_logger.log' +# shift_age = 0 +# shift_size = 1_048_576 +tl = TeeLogger.new - # let's logging - tl.debug 'hello' - tl.debug(:progname) { 'hello world' } - tl.progname = 'App' - tl.debug 'hello tee_logger' +tl.debug 'hello' +tl.debug(:progname) { 'hello world' } +tl.progname = 'App' +tl.debug 'hello tee_logger' +``` - # enable only when specified - tl.info 'this message is console and logfile' - tl.info 'this message is console only', :console - tl.info 'this message is logfile only', :logfile +### enable only when specified +```ruby +tl.info 'this message is console and logfile' +tl.info 'this message is console only', :console +tl.info 'this message is logfile only', :logfile +``` - # log meassage indent - tl.info 'hello' # => 'hello' - tl.info 'hello', 0 # => 'hello' - tl.info 'hello', 2 # => ' hello' +### log meassage indent +```ruby +tl.info 'hello' # => 'hello' +tl.info 'hello', 0 # => 'hello' +tl.info 'hello', 2 # => ' hello' +``` - # enabling and indent - tl.info 'this message is console only', 2, :console - tl.info 'this message is console only', :console, 2 +### enabling and indent +```ruby +tl.info 'this message is console only', 2, :console +tl.info 'this message is console only', :console, 2 +``` - # disable console output - tl.disable(:console) - tl.info 'this message is logfile only' +### disable console output +```ruby +tl.disable(:console) +tl.info 'this message is logfile only' +``` - # enable console output - tl.enable(:console) - tl.info 'this message is logfile and console' +### enable console output +```ruby +tl.enable(:console) +tl.info 'this message is logfile and console' +``` - # disable logfile output - tl.disable(:logfile) - tl.info 'this message is consle only' +### disable logfile output +```ruby +tl.disable(:logfile) +tl.info 'this message is consle only' +``` - # enable logfile output - tl.enable(:logfile) - tl.info 'this message is logfile and console' +### enable logfile output +```ruby +tl.enable(:logfile) +tl.info 'this message is logfile and console' +``` - # disabe in block - tl.disable(:console) do - tl.info 'this message is logfile only' - end - tl.info 'this message is logfile and console' +### disable in block +```ruby +tl.disable(:console) do + tl.info 'this message is logfile only' +end +tl.info 'this message is logfile and console' +``` - # and others like Logger's - tl.debug? # => true - tl.info? # => true - tl.warn? # => true - tl.error? # => true - tl.fatal? # => true +### and others like Logger's +```ruby +# log_level +tl.debug? # => true +tl.info? # => true +tl.warn? # => true +tl.error? # => true +tl.fatal? # => true - tl.level # => 0 - tl.level = Logger::INFO - tl.debug 'this message is not logging' +tl.level # => 0 +tl.level = Logger::INFO +tl.debug 'this message is not logging' - tl.formatter # => nil or Proc - tl.formatter = - proc { |severity, datetime, progname, message| "#{severity}:#{message}" } +# formatter +tl.formatter # => nil or Proc +tl.formatter = + proc { |severity, datetime, progname, message| "#{severity}:#{message}" } - tl.datetime_format # => nil or Proc - tl.datetime_format = '%Y%m%d %H%M%S ' +# datetime_formatter +tl.datetime_format # => nil or Proc +tl.datetime_format = '%Y%m%d %H%M%S ' ``` -## include or extend TeeLogger for casual use +## include or extend TeeLogger -> TODO: the log file will be in default of `./tee_logger.log` +> the log file will be in default of `./tee_logger.log` +### for casual use ```ruby - require 'tee_logger' +require 'tee_logger' - class YourAwesomeClass - include TeeLogger +class YourAwesomeClass + # define method #logger for your class. + # log file will be in default of `./tee_logger.log` + include TeeLogger - def awesome_method - # do somthing - logger.info 'this is message is logging and disp console' - end + def awesome_method + logger.info 'this is message is logging and disp console' end +end - module YourAwesomeModule - extend TeeLogger +module YourAwesomeModule + # define singleton method .logger for your module. + # log file will be in default of `./tee_logger.log` + extend TeeLogger - def self.awesome_method - # do somthing - logger.info 'this is message is logging and disp console' - end + def self.awesome_method + logger.info 'this is message is logging and disp console' end +end +``` + +### logfile name setting +```ruby +require 'tee_logger' + +# Before extend or include the module, allow the setting of logdev +# sorry, `TeeLogger.logev` is deprecate. +# TeeLogger.logdev = 'log1.log' +TeeLogger.configure do |config| + config.logdev = 'log1.log' +end + +class YourAwesomeClass + include TeeLogger + + def awesome_method + logger.info 'this message is output `log1.log`' + end +end + +# Before extend or include the module, allow the setting of logdev +# sorry, `TeeLogger.logev` is deprecate. +TeeLogger.logdev = 'log2.log' +module YourAwesomeModule + extend TeeLogger + + def self.awesome_method + logger.info 'this message is output `log2.log`' + end +end + ``` ## Development