Class: LogStash::Inputs::CloudWatch_Logs::SinceDB::File
- Inherits:
-
Object
- Object
- LogStash::Inputs::CloudWatch_Logs::SinceDB::File
- Defined in:
- lib/logstash/inputs/cloudwatch_logs.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #newer?(date) ⇒ Boolean
- #read ⇒ Object
- #write(since = nil) ⇒ Object
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
235 236 237 |
# File 'lib/logstash/inputs/cloudwatch_logs.rb', line 235 def newer?(date) date > read end |
#read ⇒ Object
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 |