Sha256: f382abe5d855e78adb925ad0fb981fac03d78c59de9e126239c4a8ce2c6f9f80

Contents?: true

Size: 955 Bytes

Versions: 2

Compression:

Stored size: 955 Bytes

Contents

require 'peastash/log_device'

class Peastash
  module Outputs
    class IO
      @@default_io = STDOUT

      def self.default_io
        @@default_io
      end

      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

      def dump(event)
        @device.write(event.to_json + "\n")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
peastash-0.2.7 lib/peastash/outputs/io.rb
peastash-0.2.6 lib/peastash/outputs/io.rb