Class: Console::Compatible::Logger::LogDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/console/compatible/logger.rb

Overview

A compatible log device which can be used with Console. Suitable for use with code which (incorrectly) assumes that the log device a public interface and has certain methods/behaviours.

Instance Method Summary collapse

Constructor Details

#initialize(subject, output) ⇒ LogDevice

Create a new log device.



20
21
22
23
# File 'lib/console/compatible/logger.rb', line 20

def initialize(subject, output)
  @subject = subject
  @output = output
end

Instance Method Details

#call(*arguments, **options) ⇒ Object

Log a message with the given severity.



36
37
38
# File 'lib/console/compatible/logger.rb', line 36

def call(*arguments, **options)
  @output.call(*arguments, **options)
end

#closeObject

Close the log device. This is a no-op.



45
46
# File 'lib/console/compatible/logger.rb', line 45

def close
end

#reopenObject

Reopen the log device. This is a no-op.



41
42
# File 'lib/console/compatible/logger.rb', line 41

def reopen
end

#write(message) ⇒ Object

Write a message to the log device.



28
29
30
# File 'lib/console/compatible/logger.rb', line 28

def write(message)
  @output.call(@subject, message)
end