mirror of
https://github.com/discourse/discourse.git
synced 2026-03-04 01:15:08 +08:00
This commit introduces a Rails initializer to inspect
the current status of upcoming changes and compare them
to a hidden `promote_upcoming_changes_on_status` site setting.
If the status of an upcoming change matches or exceeds this setting,
the change is automatically enabled as long as:
* The change has not been manually disabled by an admin.
* The change is not already enabled.
By default for Discourse sites, the `promote_upcoming_changes_on_status`
is set to `Stable`, on our own hosting we will change it depending
on the hosting tier and other considerations.
In a future PR, we will introduce various ways for admins to
be notified when an upcoming change is automatically promoted,
along with new upcoming changes being introduced.
**HOW TO TEST**
This is a little tricky, since it happens on rails init. First, set
`SiteSetting.enable_upcoming_changes = true` and
`SiteSetting.upcoming_change_verbose_logging = true`.
You can also set `SiteSetting.promote_upcoming_changes_on_status =
:alpha`
(by default it's `stable`)
Then, add a change like this to site_settings.yml:
```
fake_upcoming_change:
default: false
hidden: true
client: true
upcoming_change:
status: "alpha"
impact: "other,all_members"
learn_more_url: "https://meta.discourse.org"
```
And then do ` FORCE_RAILS_LOGS_STDOUT=1 brc`. After this, you should see
output like this:
```
I, [2025-11-26T16:46:54.668551 #32662] INFO -- : [Upcoming changes promoter (default)]: Starting promotion check for upcoming changes.
I, [2025-11-26T16:46:54.733353 #32662] INFO -- : [Upcoming changes promoter (default)]: Successfully promoted 'fake_upcoming_change' to enabled.
```
If you want to reset the setting and try some different status
scenarios, do
this `SiteSetting.remove_override!(:fake_upcoming_change)`
75 lines
1.3 KiB
Ruby
75 lines
1.3 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 all_messages_to_s
|
|
@debugs.each { |msg| puts "DEBUG: #{msg}" }
|
|
@infos.each { |msg| puts "INFO: #{msg}" }
|
|
@warnings.each { |msg| puts "WARN: #{msg}" }
|
|
@errors.each { |msg| puts "ERROR: #{msg}" }
|
|
@fatals.each { |msg| puts "FATAL: #{msg}" }
|
|
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
|