Class: LogStash::Outputs::SumoLogic::Compressor
- Inherits:
-
Object
- Object
- LogStash::Outputs::SumoLogic::Compressor
- Includes:
- Common
- Defined in:
- lib/logstash/outputs/sumologic/compressor.rb
Constant Summary
Constants included from Common
LogStash::Outputs::SumoLogic::Common::CARBON2, LogStash::Outputs::SumoLogic::Common::CATEGORY_HEADER, LogStash::Outputs::SumoLogic::Common::CATEGORY_HEADER_DEFAULT, LogStash::Outputs::SumoLogic::Common::CLIENT_HEADER, LogStash::Outputs::SumoLogic::Common::CLIENT_HEADER_VALUE, LogStash::Outputs::SumoLogic::Common::CONTENT_ENCODING, LogStash::Outputs::SumoLogic::Common::CONTENT_TYPE, LogStash::Outputs::SumoLogic::Common::CONTENT_TYPE_CARBON2, LogStash::Outputs::SumoLogic::Common::CONTENT_TYPE_GRAPHITE, LogStash::Outputs::SumoLogic::Common::CONTENT_TYPE_LOG, LogStash::Outputs::SumoLogic::Common::DEFAULT_LOG_FORMAT, LogStash::Outputs::SumoLogic::Common::DEFLATE, LogStash::Outputs::SumoLogic::Common::GRAPHITE, LogStash::Outputs::SumoLogic::Common::GZIP, LogStash::Outputs::SumoLogic::Common::HOST_HEADER, LogStash::Outputs::SumoLogic::Common::LOG_TO_CONSOLE, LogStash::Outputs::SumoLogic::Common::METRICS_NAME_PLACEHOLDER, LogStash::Outputs::SumoLogic::Common::NAME_HEADER, LogStash::Outputs::SumoLogic::Common::NAME_HEADER_DEFAULT, LogStash::Outputs::SumoLogic::Common::STATS_TAG, LogStash::Outputs::SumoLogic::Common::STOP_TAG
Instance Method Summary collapse
-
#compress(content) ⇒ Object
def initialize.
-
#gzip(content) ⇒ Object
def compress.
-
#initialize(config) ⇒ Compressor
constructor
A new instance of Compressor.
Methods included from Common
#log_dbg, #log_err, #log_info, #log_warn, #set_logger
Constructor Details
#initialize(config) ⇒ Compressor
Returns a new instance of Compressor.
11 12 13 14 |
# File 'lib/logstash/outputs/sumologic/compressor.rb', line 11 def initialize(config) @compress = config["compress"] @compress_encoding = (config["compress_encoding"] ||= DEFLATE).downcase end |
Instance Method Details
#compress(content) ⇒ Object
def initialize
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/logstash/outputs/sumologic/compressor.rb', line 16 def compress(content) if @compress if @compress_encoding == GZIP result = gzip(content) result.bytes.to_a.pack("c*") else Zlib::Deflate.deflate(content) end else content end end |
#gzip(content) ⇒ Object
def compress
29 30 31 32 33 34 35 36 |
# File 'lib/logstash/outputs/sumologic/compressor.rb', line 29 def gzip(content) stream = StringIO.new("w") stream.set_encoding("ASCII") gz = Zlib::GzipWriter.new(stream) gz.write(content) gz.close stream.string.bytes.to_a.pack("c*") end |