discourse/spec/support/fake_logger.rb
Loïc Guitaut 8d249457e8 DEV: Upgrade Rails to version 7.1
---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-07-04 10:58:21 +02:00

68 lines
1.0 KiB
Ruby

# frozen_string_literal: true
class FakeLogger
attr_reader :debugs, :infos, :warnings, :errors, :fatals, :severities
attr_accessor :level
def initialize
@debugs = []
@infos = []
@warnings = []
@errors = []
@fatals = []
@level = Logger::DEBUG
@severities = { 0 => :debugs, 1 => :infos, 2 => :warnings, 3 => :errors, 4 => :fatals }
end
def debug(message = nil)
@debugs << message
end
def debug?
@level <= Logger::DEBUG
end
def info(message = nil)
@infos << message
end
def info?
@level <= Logger::INFO
end
def warn(message = nil)
@warnings << message
end
def warn?
@level <= Logger::WARN
end
def error(message = nil)
@errors << message
end
def error?
@level <= Logger::ERROR
end
def fatal(message = nil)
@fatals << message
end
def fatal?
@level <= Logger::FATAL
end
def formatter
end
def add(severity, message = nil, progname = nil)
public_send(severities[severity]) << message
end
def broadcasts
[self]
end
end