Class: LogStash::Outputs::OSS::TimeBasedRotation

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/oss/rotations/time_based_rotation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time_rotate) ⇒ TimeBasedRotation

Returns a new instance of TimeBasedRotation.



8
9
10
11
12
13
# File 'lib/logstash/outputs/oss/rotations/time_based_rotation.rb', line 8

def initialize(time_rotate)
  if time_rotate <= 0
    raise LogStash::ConfigurationError, "Logstash OSS output has wrong configuration: time_rotate must be positive if strategy is `time`"
  end
  @time_rotate = time_rotate * 60
end

Instance Attribute Details

#time_rotateObject (readonly)

Returns the value of attribute time_rotate.



6
7
8
# File 'lib/logstash/outputs/oss/rotations/time_based_rotation.rb', line 6

def time_rotate
  @time_rotate
end

Instance Method Details

#needs_periodic_check?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/logstash/outputs/oss/rotations/time_based_rotation.rb', line 19

def needs_periodic_check?
  true
end

#rotate?(file) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/logstash/outputs/oss/rotations/time_based_rotation.rb', line 15

def rotate?(file)
  file.size > 0 && (Time.now - file.ctime) >= @time_rotate
end