Class: LogStash::Outputs::Qingstor::RotationPolicy::SizeAndTime

Inherits:
Policy
  • Object
show all
Defined in:
lib/logstash/outputs/qingstor/rotation_policy.rb

Instance Method Summary collapse

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

Returns:

  • (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_sObject



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