mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 14:41:25 +08:00
DEV: Redo DiscourseLogstashLogger
to not rely on logstash-logger
(#27663)
This commit rewrites `DiscourseLogstashLogger` to not be an instance of `LogstashLogger`. The reason we don't want it to be an instance of `LogstashLogger` is because we want the new logger to be chained to Logster's logger which can then pass down useful information like the request's env and error backtraces which Logster has already gathered. Note that this commit does not bother to maintain backwards compatibility and drops the `LOGSTASH_URI` and `UNICORN_LOGSTASH_URI` ENV variables which were previously used to configure the destination in which `logstash-logger` would send the logs to. Instead, we introduce the `ENABLE_LOGSTASH_LOGGER` ENV variable to replace both ENV and remove the need for the log paths to be specified. Note that the previous feature was considered experimental as stated in d888d3c54c4744d52b9d21d3728f5d6dbc132cde and the new feature should be considered experimental as well. The code may be moved into a plugin in the future.
This commit is contained in:

committed by
GitHub

parent
d8e7fc4f5d
commit
8e10878e1a
@ -4,6 +4,7 @@ require "cache"
|
||||
require "open3"
|
||||
require "plugin/instance"
|
||||
require "version"
|
||||
require "git_utils"
|
||||
|
||||
module Discourse
|
||||
DB_POST_MIGRATE_PATH ||= "db/post_migrate"
|
||||
@ -829,42 +830,23 @@ module Discourse
|
||||
end
|
||||
|
||||
def self.git_version
|
||||
@git_version ||=
|
||||
begin
|
||||
git_cmd = "git rev-parse HEAD"
|
||||
self.try_git(git_cmd, Discourse::VERSION::STRING)
|
||||
end
|
||||
@git_version ||= GitUtils.git_version
|
||||
end
|
||||
|
||||
def self.git_branch
|
||||
@git_branch ||=
|
||||
self.try_git("git branch --show-current", nil) ||
|
||||
self.try_git("git config user.discourse-version", "unknown")
|
||||
@git_branch ||= GitUtils.git_branch
|
||||
end
|
||||
|
||||
def self.full_version
|
||||
@full_version ||=
|
||||
begin
|
||||
git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null'
|
||||
self.try_git(git_cmd, "unknown")
|
||||
end
|
||||
@full_version ||= GitUtils.full_version
|
||||
end
|
||||
|
||||
def self.last_commit_date
|
||||
@last_commit_date ||=
|
||||
begin
|
||||
git_cmd = 'git log -1 --format="%ct"'
|
||||
seconds = self.try_git(git_cmd, nil)
|
||||
seconds.nil? ? nil : DateTime.strptime(seconds, "%s")
|
||||
end
|
||||
@last_commit_date ||= GitUtils.last_commit_date
|
||||
end
|
||||
|
||||
def self.try_git(git_cmd, default_value)
|
||||
begin
|
||||
`#{git_cmd}`.strip
|
||||
rescue StandardError
|
||||
default_value
|
||||
end.presence || default_value
|
||||
GitUtils.try_git(git_cmd, default_value)
|
||||
end
|
||||
|
||||
# Either returns the site_contact_username user or the first admin.
|
||||
|
Reference in New Issue
Block a user