Class: LogStash::Outputs::OSS::TimeBasedRotation
- Inherits:
-
Object
- Object
- LogStash::Outputs::OSS::TimeBasedRotation
- Defined in:
- lib/logstash/outputs/oss/rotations/time_based_rotation.rb
Instance Attribute Summary collapse
-
#time_rotate ⇒ Object
readonly
Returns the value of attribute time_rotate.
Instance Method Summary collapse
-
#initialize(time_rotate) ⇒ TimeBasedRotation
constructor
A new instance of TimeBasedRotation.
- #needs_periodic_check? ⇒ Boolean
- #rotate?(file) ⇒ Boolean
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_rotate ⇒ Object (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
19 20 21 |
# File 'lib/logstash/outputs/oss/rotations/time_based_rotation.rb', line 19 def needs_periodic_check? true end |
#rotate?(file) ⇒ 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 |