Sha256: e2fe34be4eb256ad7ba8735ea01902a7dc2b25bbb96f8a467c76f241e501712e
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
module Vizsla class RequestLogger def initialize(logger_override = nil) @logger_override = logger_override end def display_payload(payload) output = '=' * 50 + "\n" str_append_hash output, payload output += '=' * 50 log output end def str_append_hash(str, hsh, bumper = '') hsh.keys.each do |key| if hsh[key].is_a? Hash str << "#{bumper}#{key}:\n" str_append_hash str, hsh[key], bumper + ' ' elsif hsh[key].is_a? Array str << "#{bumper}#{key}:\n" hsh[key].each do |ele| if ele.is_a? Hash str_append_hash str, ele, bumper + ' ' else str << "#{bumper}#{ele}" end end else str << "#{bumper}#{key}: #{hsh[key]}\n" end end str end private def rails_app? defined? ::Rails end def log(text) if !@logger_override.nil? @logger_override.info text elsif rails_app? Rails.logger.debug text else puts text end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tracebin-0.0.7 | lib/vizsla/logger.rb |