discourse/spec/support/fake_logger.rb
Loïc Guitaut ca4af53be8 DEV: Upgrade Rails to version 7.1 (#27539)
* DEV: Upgrade Rails to 7.1

* FIX: Remove references to `Rails.logger.chained`

`Rails.logger.chained` was provided by Logster before Rails 7.1
introduced their broadcast logger. Now all the loggers are added to
`Rails.logger.broadcasts`.

Some code in our initializers was still using `chained` instead of
`broadcasts`.

* DEV: Make parameters optional to all FakeLogger methods

* FIX: Set `override_level` on Logster loggers (#27519)

A followup to f595d599dd

* FIX: Don’t duplicate Rack response

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-06-21 09:44:06 +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