You've already forked oauth2-proxy
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:
29
pkg/logger/klog.go
Normal file
29
pkg/logger/klog.go
Normal 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}
|
Reference in New Issue
Block a user