MCPcopy Create free account
hub / github.com/coder/envbuilder / HijackLogrus

Function HijackLogrus

log/logrus.go:12–19  ·  view source on GitHub ↗

HijackLogrus hijacks the logrus logger and calls the callback for each log entry. This is an abuse of logrus, the package that Kaniko uses, but it exposes no other way to obtain the log entries.

(lvl Level, callback func(entry *logrus.Entry))

Source from the content-addressed store, hash-verified

10// This is an abuse of logrus, the package that Kaniko uses, but it exposes
11// no other way to obtain the log entries.
12func HijackLogrus(lvl Level, callback func(entry *logrus.Entry)) {
13 logrus.StandardLogger().SetOutput(io.Discard)
14 logrus.StandardLogger().SetLevel(ToLogrus(lvl))
15 logrus.StandardLogger().SetFormatter(&logrusFormatter{
16 callback: callback,
17 empty: []byte{},
18 })
19}
20
21type logrusFormatter struct {
22 callback func(entry *logrus.Entry)

Callers 5

runFunction · 0.92
RunCacheProbeFunction · 0.92
TestHijackLogrus_InfoFunction · 0.92
TestHijackLogrus_DebugFunction · 0.92
TestHijackLogrus_ErrorFunction · 0.92

Calls 1

ToLogrusFunction · 0.85

Tested by 3

TestHijackLogrus_InfoFunction · 0.74
TestHijackLogrus_DebugFunction · 0.74
TestHijackLogrus_ErrorFunction · 0.74