class NetuitiveRubyApi::NetuitiveLogger

Attributes

log[RW]

Public Class Methods

format_age(age) click to toggle source
# File lib/netuitive_ruby_api/netuitive_logger.rb, line 27
def format_age(age)
  return 'daily' if age.nil?
  begin
    Integer(age)
  rescue
    age
  end
end
format_size(size) click to toggle source
# File lib/netuitive_ruby_api/netuitive_logger.rb, line 36
def format_size(size)
  return 1_000_000 if size.nil?
  begin
    Integer(size)
  rescue
    size
  end
end
setup() click to toggle source
# File lib/netuitive_ruby_api/netuitive_logger.rb, line 15
def setup
  file = NetuitiveRubyApi::ConfigManager.property('logLocation', 'NETUITIVE_RUBY_LOG_LOCATION', "#{File.expand_path('../../..', __FILE__)}/log/netuitive.log")
  age = NetuitiveRubyApi::ConfigManager.property('logAge', 'NETUITIVE_RUBY_LOG_AGE', 'daily')
  age = format_age(age)
  size = NetuitiveRubyApi::ConfigManager.property('logSize', 'NETUITIVE_RUBY_LOG_SIZE', 1_000_000)
  size = format_size(size)
  @log = Logger.new(file, age, size)
rescue => e
  puts "netuitive unable to open log file. error: #{e.message}, backtrace: #{e.backtrace}"
  @log = NetuitiveRubyApi::CheaterLogger.new
end