Class: Kino::Logger::Device
- Inherits:
-
Object
- Object
- Kino::Logger::Device
- Defined in:
- lib/kino/logger.rb
Overview
The raw IO-like device for integrations that want bytes without ::Logger's formatting: Rack::CommonLogger, ActiveSupport::Logger.new, a BroadcastLogger arm, ... Frozen and holding only an Integer id, so it is Ractor-shareable; one device can serve every worker.
Instance Method Summary collapse
-
#close ⇒ void
Close the device: the flusher drains its queue and exits.
-
#initialize(path = nil) ⇒ Device
constructor
A new instance of Device.
-
#reopen ⇒ Object
::Logger probes these on its device.
-
#write(message) ⇒ void
(also: #<<)
Queue one formatted line on the async sink; never blocks.
Constructor Details
#initialize(path = nil) ⇒ Device
Returns a new instance of Device.
32 33 34 35 |
# File 'lib/kino/logger.rb', line 32 def initialize(path = nil) @id = Native.log_device_open(path&.to_s) freeze end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
Close the device: the flusher drains its queue and exits. Writes after close are ignored.
47 48 49 |
# File 'lib/kino/logger.rb', line 47 def close Native.log_device_close(@id) end |
#reopen ⇒ Object
::Logger probes these on its device.
52 |
# File 'lib/kino/logger.rb', line 52 def reopen(*) = self |
#write(message) ⇒ void Also known as: <<
This method returns an undefined value.
Queue one formatted line on the async sink; never blocks.
40 41 42 |
# File 'lib/kino/logger.rb', line 40 def write() Native.log_device_write(@id, .to_s) end |