2020-10-21 05:49:41 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-logr/logr"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NB: this is the same as the null logger logr/testing,
|
|
|
|
// but avoids accidentally adding the testing flags to
|
|
|
|
// all binaries.
|
|
|
|
|
2021-12-08 13:50:47 +00:00
|
|
|
// NullLogSink is a logr.Logger that does nothing.
|
|
|
|
type NullLogSink struct{}
|
2020-10-21 05:49:41 +00:00
|
|
|
|
2021-12-08 13:50:47 +00:00
|
|
|
var _ logr.LogSink = NullLogSink{}
|
|
|
|
|
|
|
|
// Init implements logr.LogSink.
|
|
|
|
func (log NullLogSink) Init(logr.RuntimeInfo) {
|
|
|
|
}
|
2020-10-21 05:49:41 +00:00
|
|
|
|
2021-06-25 05:02:01 +00:00
|
|
|
// Info implements logr.InfoLogger.
|
2021-12-08 13:50:47 +00:00
|
|
|
func (NullLogSink) Info(_ int, _ string, _ ...interface{}) {
|
2020-10-21 05:49:41 +00:00
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
2021-06-25 05:02:01 +00:00
|
|
|
// Enabled implements logr.InfoLogger.
|
2021-12-08 13:50:47 +00:00
|
|
|
func (NullLogSink) Enabled(level int) bool {
|
2020-10-21 05:49:41 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-06-25 05:02:01 +00:00
|
|
|
// Error implements logr.Logger.
|
2021-12-08 13:50:47 +00:00
|
|
|
func (NullLogSink) Error(_ error, _ string, _ ...interface{}) {
|
2020-10-21 05:49:41 +00:00
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
2021-06-25 05:02:01 +00:00
|
|
|
// WithName implements logr.Logger.
|
2021-12-08 13:50:47 +00:00
|
|
|
func (log NullLogSink) WithName(_ string) logr.LogSink {
|
2020-10-21 05:49:41 +00:00
|
|
|
return log
|
|
|
|
}
|
|
|
|
|
2021-06-25 05:02:01 +00:00
|
|
|
// WithValues implements logr.Logger.
|
2021-12-08 13:50:47 +00:00
|
|
|
func (log NullLogSink) WithValues(_ ...interface{}) logr.LogSink {
|
2020-10-21 05:49:41 +00:00
|
|
|
return log
|
|
|
|
}
|