Class: LogStashLogger::Device::File
- Defined in:
- lib/logstash-logger/device/file.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(opts) ⇒ File
constructor
A new instance of File.
- #open ⇒ Object
Methods inherited from Base
#close, #flush, #to_io, #write
Constructor Details
#initialize(opts) ⇒ File
Returns a new instance of File.
6 7 8 9 10 |
# File 'lib/logstash-logger/device/file.rb', line 6 def initialize(opts) super @path = opts[:path] || fail(ArgumentError, "Path is required") open end |
Instance Method Details
#open ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/logstash-logger/device/file.rb', line 12 def open unless ::File.exist? ::File.dirname @path ::FileUtils.mkdir_p ::File.dirname @path end @io = ::File.open @path, ::File::WRONLY | ::File::APPEND | ::File::CREAT @io.binmode @io.sync = self.sync end |