Module: Lilipad::Logger

Defined in:
lib/lilipad/logger.rb

Constant Summary collapse

LOGG =
{}
TRACE =
TracePoint.new(:line) do |tp|
  # known events to ignore
  if (tp.path && (tp.path.include?("gem") || tp.path.include?("lib") || tp.path.include?("internal:"))) || tp.defined_class&.to_s&.include?("Sinatra")
    next
  end

  puts LOGG[tp.path][tp.lineno.to_s] if LOGG[tp.path] && LOGG[tp.path][tp.lineno.to_s]
end

Class Method Summary collapse

Class Method Details

.append_logg(path, lineno, msg) ⇒ Object



50
51
52
53
# File 'lib/lilipad/logger.rb', line 50

def self.append_logg(path, lineno, msg)
  LOGG[path] ||= {}
  LOGG[path][lineno.to_s] = msg
end

.disable_traceObject



55
56
57
58
59
# File 'lib/lilipad/logger.rb', line 55

def self.disable_trace
  return unless TRACE.enabled?

  TRACE.disable
end

.enable_traceObject



44
45
46
47
48
# File 'lib/lilipad/logger.rb', line 44

def self.enable_trace
  return if TRACE.enabled?

  TRACE.enable
end

.resetObject



61
62
63
# File 'lib/lilipad/logger.rb', line 61

def self.reset
  LOGG.clear
end