Module: ExcADG::Log

Defined in:
lib/excadg/log.rb

Overview

logging support

Defined Under Namespace

Classes: RLogger

Class Method Summary collapse

Class Method Details

.logger(new_logger) ⇒ Object

replaces default logger with a custom one and unmutes logging



54
55
56
57
58
# File 'lib/excadg/log.rb', line 54

def self.logger new_logger
  Assertions.is_a? new_logger, RLogger
  @main = new_logger
  unmute
end

.method_missing(method, *args, &_block) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/excadg/log.rb', line 37

def self.method_missing(method, *args, &_block)
  return if @muted

  @main ||= RLogger.new
  r = Ractor.current
  @main.send [method, r&.to_s || r.object_id, *args]
rescue Ractor::ClosedError => e
  # last hope - there is tty
  puts "can't send message to logging ractor: #{e}, message: #{args}"
end

.muteObject

mute logging by ignoring all incoming log requests



61
62
63
# File 'lib/excadg/log.rb', line 61

def self.mute
  @muted = true
end

.respond_to_missing?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/excadg/log.rb', line 48

def self.respond_to_missing?
  true
end

.unmuteObject

unmute logging for new messages



66
67
68
# File 'lib/excadg/log.rb', line 66

def self.unmute
  @muted = false
end