Class: Kafkat::Interface::KafkaLogs
- Inherits:
-
Object
- Object
- Kafkat::Interface::KafkaLogs
- Defined in:
- lib/kafkat/interface/kafka_logs.rb
Defined Under Namespace
Classes: KafkaRunningError, NoLogsError
Constant Summary collapse
- UNTRUNCATED_SIZE =
1MB
10 * 1024 * 1024
Instance Attribute Summary collapse
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
Instance Method Summary collapse
- #clean_indexes! ⇒ Object
-
#initialize(config) ⇒ KafkaLogs
constructor
A new instance of KafkaLogs.
Constructor Details
#initialize(config) ⇒ KafkaLogs
Returns a new instance of KafkaLogs.
11 12 13 |
# File 'lib/kafkat/interface/kafka_logs.rb', line 11 def initialize(config) @log_path = config.log_path end |
Instance Attribute Details
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
9 10 11 |
# File 'lib/kafkat/interface/kafka_logs.rb', line 9 def log_path @log_path end |
Instance Method Details
#clean_indexes! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/kafkat/interface/kafka_logs.rb', line 15 def clean_indexes! check_exists to_remove = [] lock_for_write do index_glob = File.join(log_path, '**/*.index') Dir[index_glob].each do |index_path| size = File.size(index_path) to_remove << index_path if size == UNTRUNCATED_SIZE end end to_remove.each do |path| print "Removing #{path}.\n" File.unlink(path) end to_remove.size end |