Class: LogStash::Outputs::Gcs::PlainLogFile

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

Overview

PlainLogFile writes events to a plain text file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PlainLogFile

Returns a new instance of PlainLogFile.



27
28
29
30
31
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 27

def initialize(path)
  @path = path
  @fd = ::File.new(path, 'a+')
  @last_sync = Time.now
end

Instance Attribute Details

#fdObject (readonly)

Returns the value of attribute fd.



25
26
27
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 25

def fd
  @fd
end

#pathObject (readonly)

Returns the value of attribute path.



25
26
27
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 25

def path
  @path
end

Instance Method Details

#close!Object



42
43
44
45
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 42

def close!
  @fd.fsync
  @fd.close
end

#fsyncObject



37
38
39
40
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 37

def fsync
  @fd.fsync
  @last_sync = Time.now
end

#sizeObject



47
48
49
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 47

def size
  ::File.stat(@path).size
end

#time_since_syncObject



51
52
53
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 51

def time_since_sync
  Time.now - @last_sync
end

#write(*contents) ⇒ Object



33
34
35
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 33

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