Files
takana/recipes/incoming-go/use-logrus-syslog-hook.patch
T
sergio 0e8d436812 Etapa G: pre-siembra cola finde (41 Go vetadas) en incoming-go/ para el worker 24/7
k8s (stern/kail/popeye/kube-score/kubeconform/kubent/polaris-no/kube-capacity/vals/helmsman),
recon projectdiscovery+tomnomnom (subfinder/naabu/katana/nuclei/gau/waybackurls/gobuster/ffuf/anew/
qsreplace/unfurl), dev (golangci-lint/gofumpt/gci/gotests/mockgen/golines/buf/bazelisk/act/gojq/sq),
security (gosec/nancy/osv-scanner/scorecard/kics/gitsign), git (git-lfs/hub/gitbatch/gotop/gh-dash),
OCI (umoci), inlets, dyff. Misimports dropeados: gf(C)/polaris(rust)/gitlab-runner+traefik(tarball).
2026-06-27 06:45:03 -04:00

44 lines
1.4 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.
diff --git a/commands/multi.go b/commands/multi.go
index e62594be6..a0c2d659b 100644
--- a/commands/multi.go
+++ b/commands/multi.go
@@ -37,6 +37,9 @@ import (
"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"
)
const (
@@ -1462,7 +1465,13 @@ func (mr *RunCommand) Execute(_ *cli.Context) {
}
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")
+ }
}
mr.sentryLogHookMutex.Lock()