Class: LogStash::Outputs::Gcs::GzipLogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/gcs/temp_log_file.rb

Overview

GzipLogFile wraps another log file and writes events through it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(child) ⇒ GzipLogFile

Returns a new instance of GzipLogFile.



60
61
62
63
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 60

def initialize(child)
  @child = child
  @fd = Zlib::GzipWriter.new(child.fd)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



81
82
83
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 81

def method_missing(method_name, *args, &block)
  @child.send(method_name, *args, &block)
end

Instance Attribute Details

#fdObject (readonly)

Returns the value of attribute fd.



58
59
60
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 58

def fd
  @fd
end

Instance Method Details

#close!Object



74
75
76
77
78
79
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 74

def close!
  fsync
  # The Gzip writer closes the underlying IO after
  # appending the Gzip footer.
  @fd.close
end

#fsyncObject



69
70
71
72
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 69

def fsync
  @fd.flush
  @child.fsync
end

#write(*contents) ⇒ Object



65
66
67
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 65

def write(*contents)
  contents.each { |c| @fd.write(c) }
end