Class: Onlylogs::SocketLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/onlylogs/socket_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_fallback: $stdout, socket_path: ENV.fetch("ONLYLOGS_SIDECAR_SOCKET", SocketDevice::DEFAULT_SOCKET)) ⇒ SocketLogger

Returns a new instance of SocketLogger.



16
17
18
19
# File 'lib/onlylogs/socket_logger.rb', line 16

def initialize(local_fallback: $stdout, socket_path: ENV.fetch("ONLYLOGS_SIDECAR_SOCKET", SocketDevice::DEFAULT_SOCKET))
  @device = SocketDevice.new(socket_path: socket_path)
  super(MultiDevice.new(local_fallback, @device))
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



14
15
16
# File 'lib/onlylogs/socket_logger.rb', line 14

def device
  @device
end

Instance Method Details

#closeObject

Only the remote socket is ours to close; the local fallback ($stdout) belongs to the app, so we deliberately do not call super (which would close the whole log device, fallback included).



23
24
25
# File 'lib/onlylogs/socket_logger.rb', line 23

def close
  @device.close
end