1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-22 18:55:29 +03:00
aports/community/gitlab-runner/use-logrus-syslog-hook.patch
2022-10-23 03:41:29 +02:00

42 lines
1.3 KiB
Diff

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)