1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-21 00:29:44 +02:00

Set up klog to write to our custom logger

This commit is contained in:
Joel Speed
2021-03-28 21:11:34 +01:00
parent fd5e23e1c5
commit 95464ca58f
5 changed files with 71 additions and 3 deletions

29
pkg/logger/klog.go Normal file
View File

@ -0,0 +1,29 @@
package logger
// KlogInfoLogger is used for info level log output in Klog
type KlogInfoLogger struct {
logger *Logger
}
// Write is used to output klog log lines
func (l *KlogInfoLogger) Write(data []byte) (int, error) {
l.logger.Output(DEFAULT, 6, string(data))
return len(data), nil
}
// KlogInfoLogger is used for error level log output in Klog
type KlogErrorLogger struct {
logger *Logger
}
// Write is used to output klog log lines
func (l *KlogErrorLogger) Write(data []byte) (int, error) {
l.logger.Output(ERROR, 6, string(data))
return len(data), nil
}
// StdKlogInfoLogger is an info logger using the standard logger
var StdKlogInfoLogger = &KlogInfoLogger{logger: std}
// StdKlogErrorLogger is an info logger using the standard logger
var StdKlogErrorLogger = &KlogErrorLogger{logger: std}