2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-14 12:50:26 +08:00
|
|
|
require "logstash-logger"
|
|
|
|
|
|
|
|
class DiscourseLogstashLogger
|
2024-06-12 13:34:07 +08:00
|
|
|
def self.logger(uri:, type:)
|
2017-11-14 12:50:26 +08:00
|
|
|
LogStashLogger.new(
|
|
|
|
uri: uri,
|
|
|
|
sync: true,
|
|
|
|
customize_event: ->(event) do
|
|
|
|
event["severity_name"] = event["severity"]
|
2017-11-17 08:54:53 +08:00
|
|
|
event["severity"] = Object.const_get("Logger::Severity::#{event["severity"]}")
|
2017-11-14 12:50:26 +08:00
|
|
|
event["type"] = type
|
2018-04-17 12:07:13 +08:00
|
|
|
event["pid"] = Process.pid
|
2017-11-14 12:50:26 +08:00
|
|
|
end,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|