Class: Fluent::TailInput::PositionFile
- Inherits:
-
Object
- Object
- Fluent::TailInput::PositionFile
- Defined in:
- lib/fluent/plugin/in_tail.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](path) ⇒ Object
-
#initialize(file, map, last_pos) ⇒ PositionFile
constructor
A new instance of PositionFile.
Constructor Details
#initialize(file, map, last_pos) ⇒ PositionFile
Returns a new instance of PositionFile.
1222 1223 1224 1225 1226 |
# File 'lib/fluent/plugin/in_tail.rb', line 1222 def initialize(file, map, last_pos) @file = file @map = map @last_pos = last_pos end |
Class Method Details
.parse(file) ⇒ Object
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
# File 'lib/fluent/plugin/in_tail.rb', line 1243 def self.parse(file) map = {} file.pos = 0 file.each_line {|line| m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line) next unless m path = m[1] pos = m[2].to_i(16) ino = m[3].to_i(16) seek = file.pos - line.bytesize + path.bytesize + 1 map[path] = FilePositionEntry.new(file, seek) } new(file, map, file.pos) end |
Instance Method Details
#[](path) ⇒ Object
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
# File 'lib/fluent/plugin/in_tail.rb', line 1228 def [](path) if m = @map[path] return m end @file.pos = @last_pos @file.write path @file.write "\t" seek = @file.pos @file.write "0000000000000000\t00000000\n" @last_pos = @file.pos @map[path] = FilePositionEntry.new(@file, seek) end |