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))
| 10 | // This is an abuse of logrus, the package that Kaniko uses, but it exposes |
| 11 | // no other way to obtain the log entries. |
| 12 | func 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 | |
| 21 | type logrusFormatter struct { |
| 22 | callback func(entry *logrus.Entry) |