Class: LogStash::Outputs::Qingstor::RotationPolicy::SizeAndTime
- Defined in:
- lib/logstash/outputs/qingstor/rotation_policy.rb
Instance Method Summary collapse
-
#initialize(file_size, file_time) ⇒ SizeAndTime
constructor
A new instance of SizeAndTime.
- #rotate?(file) ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Policy
#name, #needs_periodic?, #positive_check
Constructor Details
#initialize(file_size, file_time) ⇒ SizeAndTime
Returns a new instance of SizeAndTime.
59 60 61 62 |
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 59 def initialize(file_size, file_time) @file_size, @file_time = file_size, file_time positive_check(file_size, file_time) end |
Instance Method Details
#rotate?(file) ⇒ Boolean
64 65 66 67 |
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 64 def rotate?(file) (!file.empty? && (::Time.now - file.ctime) >= @file_time) || (file.size >= @file_size) end |
#to_s ⇒ Object
69 70 71 72 |
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 69 def to_s { :policy => name, :file_time => @file_time, :file_size => @file_size }.to_s end |