Class: Peastash::Outputs::IO
- Inherits:
-
Object
- Object
- Peastash::Outputs::IO
- Defined in:
- lib/peastash/outputs/io.rb
Constant Summary collapse
- @@default_io =
STDOUT
Class Method Summary collapse
Instance Method Summary collapse
- #dump(event) ⇒ Object
-
#initialize(file, *args) ⇒ IO
constructor
A new instance of IO.
Constructor Details
#initialize(file, *args) ⇒ IO
Returns a new instance of IO.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/peastash/outputs/io.rb', line 12 def initialize(file, *args) if file.is_a?(String) # Rewrite symlink path to realpath for instance # /home/app/releases/20190528155050/log/logstash.log -> /home/app/shared/log/logstash.log # if the symlinked folder gets deleted on further releases, the log rotation will fail with # a long wait ending with : log rotation inter-process lock failed. # realpath is called without the filename because it expects the full path to exists dir = File.realpath(File.dirname(file)) name = File.basename(file) file = "#{dir}/#{name}" end @device = ::Peastash::LogDevice.new(file, *args) end |
Class Method Details
.default_io ⇒ Object
8 9 10 |
# File 'lib/peastash/outputs/io.rb', line 8 def self.default_io @@default_io end |
Instance Method Details
#dump(event) ⇒ Object
26 27 28 |
# File 'lib/peastash/outputs/io.rb', line 26 def dump(event) @device.write(event.to_json + "\n") end |