Sha256: b8c6f51f3923685290e44a50eb213ffab76160ecc37ad6a5b114f44ce132487c

Contents?: true

Size: 892 Bytes

Versions: 28

Compression:

Stored size: 892 Bytes

Contents

require 'singleton'
require_relative 'condition_utils'

module Antrapol
  module ToolRack
 
    class Logger
      include Singleton
      include Antrapol::ToolRack::ConditionUtils

      attr_reader :glogger
      def initialize
        # boolean
        loggerDebug = ENV['TOOLRACK_DEBUG']
        logFile = ENV['TOOLRACK_LOGFILE'] || File.join(Dir.home, 'antrapol_logs','toolrack.log')
        maxLogNo = ENV['TOOLRACK_MAX_LOGFILE'] || 10
        logFileSize = ENV['TOOLRACK_MAX_LOGFILE_SIZE'] || 10*1024*1024

        logFileDir = File.dirname(logFile)
        if not File.exist?(logFileDir)
          FileUtils.mkdir_p(logFileDir)
        end
        
        if not_empty?(loggerDebug) and (loggerDebug.downcase == 'true')
          @glogger = Tlogger.new(STDOUT)
        else
          @glogger = Tlogger.new(logFile,maxLogNo,logFileSize)
        end
      end
    end
  
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
toolrack-0.9.0 lib/toolrack/global.rb
toolrack-0.8.2 lib/toolrack/global.rb
toolrack-0.8.1 lib/toolrack/global.rb
toolrack-0.7.0 lib/toolrack/global.rb
toolrack-0.6.2 lib/toolrack/global.rb
toolrack-0.6.1 lib/toolrack/global.rb
toolrack-0.6.0 lib/toolrack/global.rb
toolrack-0.5.3 lib/toolrack/global.rb