class SmartProxyDynflowCore::Log

Public Class Methods

instance() click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 9
def instance
  if @logger.nil?
    @logger = self.new log_file
    @logger.level = log_level
  end
  @logger
end
instance=(logger) click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 17
def instance=(logger)
  @logger = logger
end
log_file() click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 34
def log_file
  if Settings.instance.loaded && Settings.instance.log_file
    Settings.instance.log_file
  else
    $stdout
  end
end
log_level() click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 26
def log_level
  if Settings.instance.loaded && Settings.instance.log_level
    ::Logger.const_get(Settings.instance.log_level.upcase)
  else
    Logger::WARN
  end
end
new(file, *rest) click to toggle source
Calls superclass method
# File lib/smart_proxy_dynflow_core/log.rb, line 43
def initialize(file, *rest)
  @file = file
  @fd = @file.kind_of?(IO) ? @file : File.open(@file, 'a')
  @fd.sync = true
  super(@fd, rest)
end
reload!() click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 21
def reload!
  @logger = nil
  instance
end

Public Instance Methods

roll_log() click to toggle source
# File lib/smart_proxy_dynflow_core/log.rb, line 50
def roll_log
  unless @file.kind_of? IO
    @fd.reopen @file, 'a'
    @fd.sync = true
  end
end