aboutsummaryrefslogtreecommitdiffstats
path: root/community/gitlab-runner/use-logrus-syslog-hook.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/gitlab-runner/use-logrus-syslog-hook.patch')
-rw-r--r--community/gitlab-runner/use-logrus-syslog-hook.patch42
1 files changed, 42 insertions, 0 deletions
diff --git a/community/gitlab-runner/use-logrus-syslog-hook.patch b/community/gitlab-runner/use-logrus-syslog-hook.patch
new file mode 100644
index 00000000000..676e65d4875
--- /dev/null
+++ b/community/gitlab-runner/use-logrus-syslog-hook.patch
@@ -0,0 +1,42 @@
+Replace gitlab-runner/log/system_logger with standard logrus/hooks/syslog.
+There are two reasons:
+
+1. gitlab-runner/log/system_logger delegates the syslog initialization
+ (syslog.Dial) to kardianos/service, which doesn't set the syslog
+ facility. This results in messages logged with the "kern" facility.
+2. gitlab-runner/log/system_logger maps Error, Panic, and Fatal levels
+ to the syslog's "err" level, but Panic and Fatal could be mapped to
+ the "crit" level.
+
+I didn't contribute this patch to the upstream because I don't wanna
+contribute to any Go projects. However, if you find this patch useful,
+feel free to send it to the upstream under your name.
+
+--- a/commands/multi.go
++++ b/commands/multi.go
+@@ -30,6 +30,9 @@
+ "gitlab.com/gitlab-org/gitlab-runner/log"
+ "gitlab.com/gitlab-org/gitlab-runner/network"
+ "gitlab.com/gitlab-org/gitlab-runner/session"
++
++ "log/syslog"
++ lSyslog "github.com/sirupsen/logrus/hooks/syslog"
+ )
+
+ var (
+@@ -997,7 +1000,13 @@
+ }
+
+ if mr.Syslog {
+- log.SetSystemLogger(logrus.StandardLogger(), svc)
++ hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_DAEMON | syslog.LOG_INFO, mr.ServiceName)
++ if err == nil {
++ logrus.AddHook(hook)
++ } else {
++ logrus.WithError(err).
++ Error("Error while setting up the system logger")
++ }
+ }
+
+ logrus.AddHook(&mr.sentryLogHook)
+