Class: RedisLogstash::Logger
- Inherits:
-
Object
- Object
- RedisLogstash::Logger
- Defined in:
- lib/redis_logstash/logger.rb
Constant Summary collapse
- @@options =
nil
Class Method Summary collapse
- .filter(hash) ⇒ Object
- .gzip(source, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) ⇒ Object
- .options ⇒ Object
- .truncate_hash(hash, length = 15) ⇒ Object
- .write(hash) ⇒ Object
Class Method Details
.filter(hash) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/redis_logstash/logger.rb', line 11 def filter(hash) if [:truncate][:enabled] hash[:params] = truncate_hash(hash[:params], [:truncate][:length]) hash[:flash] = truncate_hash(hash[:flash], [:truncate][:length]) end hash[:params] = "#{hash[:params]}" hash[:flash] = "#{hash[:flash]}" hash end |
.gzip(source, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY) ⇒ Object
47 48 49 50 51 52 53 |
# 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 ⇒ Object
25 26 27 |
# File 'lib/redis_logstash/logger.rb', line 25 def @@options ||= ParseConfig.get[:logs] end |
.truncate_hash(hash, length = 15) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 |