Class: Onlylogs::SocketLogger
- Defined in:
- lib/onlylogs/socket_logger.rb
Constant Summary collapse
- DEFAULT_SOCKET =
"tmp/sockets/onlylogs-sidecar.sock"
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object
-
#initialize(local_fallback: $stdout, socket_path: ENV.fetch("ONLYLOGS_SIDECAR_SOCKET", DEFAULT_SOCKET)) ⇒ SocketLogger
constructor
A new instance of SocketLogger.
Constructor Details
#initialize(local_fallback: $stdout, socket_path: ENV.fetch("ONLYLOGS_SIDECAR_SOCKET", DEFAULT_SOCKET)) ⇒ SocketLogger
Returns a new instance of SocketLogger.
13 14 15 16 17 18 |
# File 'lib/onlylogs/socket_logger.rb', line 13 def initialize(local_fallback: $stdout, socket_path: ENV.fetch("ONLYLOGS_SIDECAR_SOCKET", DEFAULT_SOCKET)) super(local_fallback) @socket_path = socket_path @socket_mutex = Mutex.new @socket = nil end |
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/onlylogs/socket_logger.rb', line 20 def add(severity, = nil, progname = nil, &block) if .nil? if block_given? = block.call else = progname progname = nil end end formatted = (format_severity(severity), Time.now, progname, .to_s) send_to_socket(formatted) super(severity, , progname, &block) end |