Method: Concurrently::Proc.error_log_output=

Defined in:
lib/all/concurrently/proc.rb

.error_log_output=(output) ⇒ Object

Sets the output to which errors in concurrent procs are written to.

By default, errors are written to stderr. To disable logging of errors, set the output to nil or false.

Examples:

require 'logger'
Concurrently::Proc.error_log_output = Logger.new(STDOUT)

Parameters:

  • output (IO|Logger|false|nil)

Since:

  • 1.2.0



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/all/concurrently/proc.rb', line 102

def self.error_log_output=(output)
  if Object.const_defined? :Logger and Logger === output
    @error_handler.cancel if @error_handler
    @error_handler = on(:error){ |error| output.error Proc.default_error_log_message self, error }
  elsif IO === output
    @error_handler.cancel if @error_handler
    @error_handler = on(:error){ |error| output.puts Proc.default_error_log_message self, error }
  elsif !output
    remove_instance_variable(:@error_handler).cancel if @error_handler
  else
    raise Error, "output no logger or IO"
  end
end