log.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package log
  14. import (
  15. "fmt"
  16. "k8s.io/klog"
  17. )
  18. const logFmt = "kubelet config controller: %s"
  19. // Errorf shim that inserts "kubelet config controller" at the beginning of the log message,
  20. // while still reporting the call site of the logging function.
  21. func Errorf(format string, args ...interface{}) {
  22. var s string
  23. if len(args) > 0 {
  24. s = fmt.Sprintf(format, args...)
  25. } else {
  26. s = format
  27. }
  28. klog.ErrorDepth(1, fmt.Sprintf(logFmt, s))
  29. }
  30. // Infof shim that inserts "kubelet config controller" at the beginning of the log message,
  31. // while still reporting the call site of the logging function.
  32. func Infof(format string, args ...interface{}) {
  33. var s string
  34. if len(args) > 0 {
  35. s = fmt.Sprintf(format, args...)
  36. } else {
  37. s = format
  38. }
  39. klog.InfoDepth(1, fmt.Sprintf(logFmt, s))
  40. }