Sha256: 978a669b41bc1255493aa8eba31d92005e3c79b4266061bf39767a3db2d46d5d

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

# encoding: utf-8
module Ayadn
  class Errors
    def self.global_error(where, args, error)
      [where, args, error].each do |el|
        self.detokenize(el)
      end
      Logs.rec.error "--BEGIN--"
      Logs.rec.error "#{error}"
      Logs.rec.debug "LOCATION: #{where}"
      Logs.rec.debug "DATA: #{args}" unless args.nil?
      Logs.rec.debug "STACK: #{caller}"
      Logs.rec.error "--END--"
      puts "\n(error logged in #{Settings.config[:paths][:log]}/ayadn.log)\n".color(:blue)
      #raise error
      exit
    end
    def self.error(status)
      Logs.rec.error status
    end
    def self.warn(warning)
      Logs.rec.warn warning
    end
    def self.info(msg)
      Logs.rec.info msg
    end
    def self.repost(repost, original)
      Logs.rec.info "Post #{repost} is a repost. Using original: #{original}."
    end

    private

    def self.detokenize(string)
      string.dup.to_s.gsub!(/token=[a-zA-Z0-9_-]+/, "token=XXX") unless string.nil?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ayadn-1.0.7 lib/ayadn/errors.rb
ayadn-1.0.6 lib/ayadn/errors.rb
ayadn-1.0.5 lib/ayadn/errors.rb
ayadn-1.0.4 lib/ayadn/errors.rb