class QuickML::Logger

Constants

ML_LOG_FILE

Public Class Methods

new(log_filename, verbose_mode = nil) click to toggle source
# File vendor/qwik/lib/qwik/ml-logger.rb, line 21
def initialize (log_filename, verbose_mode = nil)
  @mutex = Mutex.new
  log_path = log_filename.path
  log_path.parent.check_directory
  @log_file = log_path.open('a')
  @log_file.sync = true
  @verbose_mode = verbose_mode
end

Public Instance Methods

log(msg) click to toggle source
# File vendor/qwik/lib/qwik/ml-logger.rb, line 30
def log (msg)
  puts_log(msg)
end
reopen() click to toggle source
# File vendor/qwik/lib/qwik/ml-logger.rb, line 38
def reopen
  @mutex.synchronize {
    log_filename = @log_file.path
    @log_file.close
    @log_file = File.open(log_filename, 'a')
  }
end
vlog(msg) click to toggle source
# File vendor/qwik/lib/qwik/ml-logger.rb, line 34
def vlog (msg)
  puts_log(msg) if @verbose_mode
end

Private Instance Methods

puts_log(msg) click to toggle source
# File vendor/qwik/lib/qwik/ml-logger.rb, line 48
def puts_log (msg)
  @mutex.synchronize {
    time = Time.now.strftime('%Y-%m-%dT%H:%M:%S')
    str = "#{time}: #{msg}"
    @log_file.puts str
    $stdout.puts str if $ml_debug
  }
end