Sha256: b2aa5715dff50b2391edd4683ecb0b10e3c9c01a9f15e066882aff549652c3a7

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 KB

Contents

module Keystone
  
  #
  # ログレベルに関してのローカルルール(ログ確認に関して)
  # debug    対応不要
  # info     対応不要
  # warn     複数個で営業時間内対応
  # notice   1つで営業時間内対応
  # error    1つで営業時間内対応
  # alert    複数個で即時対応
  # critical 1つで即時対応
  #
  module Base
    def log(log_type,message, is_base_info = true)
      if is_base_info
        puts "[#{Time.now.strftime("%Y/%m/%d %H:%M:%S")}][#{$$}][#{log_type.to_s}] #{message}"
      else
        puts "[#{log_type.to_s}] #{message}"
      end
    end

    def error(message)
      if message.is_a? Exception
        log(:ERROR,"#{message.message}")
        message.backtrace.each_with_index {|line, i|
          log(:ERROR,"#{line})",false)
        }
      else
        log(:ERROR,message.to_s)
      end
    end

    def info(message)
      log(:INFO,message)
    end

    def warn(message)
      log(:WARN,message)
    end

    def notice(message)
      log(:NOTICE,message)
    end
    
    def alert(message)
      log(:ALERT,message)
    end    

    def critical(message)
      log(:CRIT,message)
    end    

    def debug(message)
      if $DEBUG
        log(:DEBUG,message)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kanamei-keystone-0.0.18 lib/keystone/base.rb
kanamei-keystone-0.0.19 lib/keystone/base.rb
kanamei-keystone-0.0.20 lib/keystone/base.rb
kanamei-keystone-0.0.21 lib/keystone/base.rb
kanamei-keystone-0.0.22 lib/keystone/base.rb
kanamei-keystone-0.0.23 lib/keystone/base.rb
kanamei-keystone-0.0.24 lib/keystone/base.rb
kanamei-keystone-0.0.25 lib/keystone/base.rb
kanamei-keystone-0.0.26 lib/keystone/base.rb
kanamei-keystone-0.0.27 lib/keystone/base.rb