Module: Rack::SimpleAuth::Logger

Defined in:
lib/rack/simple_auth/logger.rb

Overview

class Logger This class receives a logpath, env and message and prints the message to the specified logpath for the proper env file (eg.: /path/to/file/test_error.log for test env)

Class Method Summary collapse

Class Method Details

.log(logpath, verbose, env, msg) ⇒ Object

Create Logfile

Parameters:

  • logpath (String)
    path to logfile
  • verbose (TrueClass|FalseClass)
    if true print to stdout
  • msg (String)
    Message defined by each Authorization class


13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/simple_auth/logger.rb', line 13

def self.log(logpath, verbose, env, msg)
  if logpath
    system("mkdir #{logpath}") unless Dir.exist?("#{logpath}")
    open("#{logpath}/#{env}_error.log", 'a') do |f|
      f << "#{msg}\n"
    end
  end

  puts msg if verbose
end