class RedisLogstash::Logger
Public Class Methods
filter(hash)
click to toggle source
# File lib/redis_logstash/logger.rb, line 11 def filter(hash) if options[:truncate][:enabled] hash[:params] = truncate_hash(hash[:params], options[:truncate][:length]) hash[:flash] = truncate_hash(hash[:flash], options[:truncate][:length]) end hash[:params] = "#{hash[:params]}" hash[:flash] = "#{hash[:flash]}" hash end
gzip(source, level=Zlib::DEFAULT_COMPRESSION, strategy=Zlib::DEFAULT_STRATEGY)
click to toggle source
# File lib/redis_logstash/logger.rb, line 47 def gzip(source, level=Zlib::DEFAULT_COMPRESSION, strategy=Zlib::DEFAULT_STRATEGY) output = StringIO.new("w") gz = Zlib::GzipWriter.new(output, level, strategy) gz.write(source) gz.close output.string end
options()
click to toggle source
# File lib/redis_logstash/logger.rb, line 25 def options @@options ||= ParseConfig.get[:logs] end
truncate_hash(hash, length = 15)
click to toggle source
# File lib/redis_logstash/logger.rb, line 29 def truncate_hash(hash, length = 15) new_hash = {} hash.to_hash.each_pair do |key, value| if value.blank? new_hash[key] = '' elsif value.instance_of? String new_hash[key] = value.truncate(length) elsif value.instance_of? Hash new_hash[key] = truncate_hash(value) else new_hash[key] = '[R]' end end new_hash end
write(hash)
click to toggle source
# File lib/redis_logstash/logger.rb, line 7 def write(hash) Socket.write(filter(hash)) end