Sha256: cd5e368921e08f08a38aa1fa7ffd80f2950d7aced667b3d95f281537baac5304

Contents?: true

Size: 817 Bytes

Versions: 6

Compression:

Stored size: 817 Bytes

Contents

module Rack
  module SimpleAuth
    # 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)
    module Logger
      # Create Logfile
      #
      # @param [String] logpath [path to logfile]
      # @param [TrueClass|FalseClass] verbose [if true print to stdout]
      # @param [String] msg [Message defined by each Authorization class]
      #
      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
    end # Logger
  end # SimpleAuth
end # Rack

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rack-simple_auth-1.0.7 lib/rack/simple_auth/logger.rb
rack-simple_auth-1.0.6 lib/rack/simple_auth/logger.rb
rack-simple_auth-1.0.5 lib/rack/simple_auth/logger.rb
rack-simple_auth-1.0.3 lib/rack/simple_auth/logger.rb
rack-simple_auth-1.0.2 lib/rack/simple_auth/logger.rb
rack-simple_auth-1.0.1 lib/rack/simple_auth/logger.rb