2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-13 23:50:26 -05:00
|
|
|
require 'logstash-logger'
|
|
|
|
|
|
|
|
class DiscourseLogstashLogger
|
|
|
|
def self.logger(uri:, type:)
|
|
|
|
LogStashLogger.new(
|
|
|
|
uri: uri,
|
|
|
|
sync: true,
|
|
|
|
customize_event: ->(event) {
|
|
|
|
event['hostname'] = `hostname`.chomp
|
|
|
|
event['severity_name'] = event['severity']
|
2017-11-16 19:54:53 -05:00
|
|
|
event['severity'] = Object.const_get("Logger::Severity::#{event['severity']}")
|
2017-11-13 23:50:26 -05:00
|
|
|
event['type'] = type
|
2018-04-17 00:07:13 -04:00
|
|
|
event['pid'] = Process.pid
|
2017-11-13 23:50:26 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|