Class: LogStash::Inputs::CloudWatch_Logs::SinceDB::File

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/cloudwatch_logs.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ File

Returns a new instance of File.



231
232
233
# File 'lib/logstash/inputs/cloudwatch_logs.rb', line 231

def initialize(file)
  @sincedb_path = file
end

Instance Method Details

#newer?(date) ⇒ Boolean

Returns:

  • (Boolean)


235
236
237
# File 'lib/logstash/inputs/cloudwatch_logs.rb', line 235

def newer?(date)
  date > read
end

#readObject



239
240
241
242
243
244
245
246
# File 'lib/logstash/inputs/cloudwatch_logs.rb', line 239

def read
  if ::File.exists?(@sincedb_path)
    since = ::File.read(@sincedb_path).chomp.strip.to_i
  else
    since = 1
  end
  return since
end

#write(since = nil) ⇒ Object



248
249
250
251
# File 'lib/logstash/inputs/cloudwatch_logs.rb', line 248

def write(since = nil)
  since = DateTime.now.strftime('%Q') if since.nil?
  ::File.open(@sincedb_path, 'w') { |file| file.write(since.to_s) }
end