mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 14:48:44 +08:00
A minimal format + suppression of noisy logs. ``` ❯ bin/ember-cli -u Ember CLI running on PID: 72251 Starting Pitchfork... Starting CSS change watcher [ember-cli] Proxying to http://127.0.0.1:3000 [ember-cli] building... Pitchfork ready on http://localhost:3000 (3 workers, 1 sidekiq, plugin JS watcher) Compiling 43 plugins... Finished initial compilation of plugins in 2.5s ... ``` <details><summary>Previously</summary><pre> Ember CLI running on PID: 73296 Starting CSS change watcher I, [2026-05-13T18:44:58.017891 #73297] INFO -- : listening on addr=127.0.0.1:3000 fd=19 [ember-cli] Proxying to http://127.0.0.1:3000 [ember-cli] building... I, [2026-05-13T18:45:05.459057 #73297] INFO -- : monitor pid=73297 ready I, [2026-05-13T18:45:05.459338 #73297] INFO -- : monitor process ready I, [2026-05-13T18:45:05.459501 #73297] INFO -- : service gen=0 spawning... I, [2026-05-13T18:45:05.486370 #73297] INFO -- : worker=0 gen=0 spawning... I, [2026-05-13T18:45:05.501127 #73297] INFO -- : worker=1 gen=0 spawning... I, [2026-05-13T18:45:05.504624 #73452] INFO -- : starting 1 supervised sidekiqs I, [2026-05-13T18:45:05.517574 #73297] INFO -- : worker=2 gen=0 spawning... I, [2026-05-13T18:45:05.527786 #73453] INFO -- : worker=0 gen=0 pid=73453 ready I, [2026-05-13T18:45:05.542901 #73454] INFO -- : worker=1 gen=0 pid=73454 ready I, [2026-05-13T18:45:05.546845 #73297] INFO -- : service gen=0 pid=73452 spawned I, [2026-05-13T18:45:05.547308 #73297] INFO -- : worker=0 gen=0 pid=73453 registered I, [2026-05-13T18:45:05.547502 #73297] INFO -- : worker=1 gen=0 pid=73454 registered I, [2026-05-13T18:45:05.568697 #73297] INFO -- : worker=2 gen=0 pid=73455 registered I, [2026-05-13T18:45:05.574660 #73455] INFO -- : worker=2 gen=0 pid=73455 ready I, [2026-05-13T18:45:05.868738 #73456] INFO -- : Loading Sidekiq in process id 73456 writing pid file /Users/cvx/discourse/discourse/tmp/pids/plugin_js_watcher_0.pid for 73464 I, [2026-05-13T18:45:06.229162 #73464] INFO -- : [PluginJsWatcher] Loading PluginJsWatcher in process id 73464 [Plugin::JsManager] Compiling 43 plugins... [Plugin::JsManager] Finished initial compilation of plugins in 1.95s ... </pre></details>
36 lines
841 B
Ruby
Vendored
36 lines
841 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
# Compact dev log formatter: drops timestamp and pid.
|
|
# Prefixes a severity label for file log, drops the prefix
|
|
# applies color to the whole message instead.
|
|
class DevLogFormatter < ::Logger::Formatter
|
|
SEVERITY_COLORS = {
|
|
"DEBUG" => "\e[90m",
|
|
"WARN" => "\e[33m",
|
|
"ERROR" => "\e[31m",
|
|
"FATAL" => "\e[1;31m",
|
|
"UNKNOWN" => "\e[35m",
|
|
}.freeze
|
|
RESET = "\e[0m"
|
|
|
|
attr_reader :color
|
|
|
|
def initialize(color: false)
|
|
super()
|
|
@color = color
|
|
end
|
|
|
|
def colored
|
|
clone.tap { |f| f.instance_variable_set(:@color, true) }
|
|
end
|
|
|
|
def call(severity, _time, _progname, msg)
|
|
message = msg2str(msg)
|
|
if @color
|
|
code = SEVERITY_COLORS[severity]
|
|
code ? "#{code}#{message}#{RESET}\n" : "#{message}\n"
|
|
else
|
|
"#{severity.ljust(5)} #{message}\n"
|
|
end
|
|
end
|
|
end
|