Class: LogStash::Outputs::Gcs::PlainLogFile
- Inherits:
-
Object
- Object
- LogStash::Outputs::Gcs::PlainLogFile
- Defined in:
- lib/logstash/outputs/gcs/temp_log_file.rb
Overview
PlainLogFile writes events to a plain text file.
Instance Attribute Summary collapse
-
#fd ⇒ Object
readonly
Returns the value of attribute fd.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close! ⇒ Object
- #fsync ⇒ Object
-
#initialize(path) ⇒ PlainLogFile
constructor
A new instance of PlainLogFile.
- #size ⇒ Object
- #time_since_sync ⇒ Object
- #write(*contents) ⇒ Object
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
#fd ⇒ Object (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 |
#path ⇒ Object (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 |
#fsync ⇒ Object
37 38 39 40 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 37 def fsync @fd.fsync @last_sync = Time.now end |
#size ⇒ Object
47 48 49 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 47 def size ::File.stat(@path).size end |
#time_since_sync ⇒ Object
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 |