Fix dependencies
This commit is contained in:
16
vendor/k8s.io/klog/.travis.yml
generated
vendored
Normal file
16
vendor/k8s.io/klog/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
language: go
|
||||
go_import_path: k8s.io/klog
|
||||
dist: xenial
|
||||
go:
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.12.x
|
||||
script:
|
||||
- go get -t -v ./...
|
||||
- diff -u <(echo -n) <(gofmt -d .)
|
||||
- diff -u <(echo -n) <(golint $(go list -e ./...))
|
||||
- go tool vet . || go vet .
|
||||
- go test -v -race ./...
|
||||
install:
|
||||
- go get golang.org/x/lint/golint
|
2
vendor/k8s.io/klog/v2/CONTRIBUTING.md → vendor/k8s.io/klog/CONTRIBUTING.md
generated
vendored
2
vendor/k8s.io/klog/v2/CONTRIBUTING.md → vendor/k8s.io/klog/CONTRIBUTING.md
generated
vendored
@ -10,7 +10,7 @@ We have full documentation on how to get started contributing here:
|
||||
|
||||
- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests
|
||||
- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing)
|
||||
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet) - Common resources for existing developers
|
||||
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet.md) - Common resources for existing developers
|
||||
|
||||
## Mentorship
|
||||
|
0
vendor/k8s.io/klog/v2/LICENSE → vendor/k8s.io/klog/LICENSE
generated
vendored
0
vendor/k8s.io/klog/v2/LICENSE → vendor/k8s.io/klog/LICENSE
generated
vendored
0
vendor/k8s.io/klog/v2/OWNERS → vendor/k8s.io/klog/OWNERS
generated
vendored
0
vendor/k8s.io/klog/v2/OWNERS → vendor/k8s.io/klog/OWNERS
generated
vendored
8
vendor/k8s.io/klog/v2/README.md → vendor/k8s.io/klog/README.md
generated
vendored
8
vendor/k8s.io/klog/v2/README.md → vendor/k8s.io/klog/README.md
generated
vendored
@ -29,14 +29,12 @@ How to use klog
|
||||
===============
|
||||
- Replace imports for `github.com/golang/glog` with `k8s.io/klog`
|
||||
- Use `klog.InitFlags(nil)` explicitly for initializing global flags as we no longer use `init()` method to register the flags
|
||||
- You can now use `log_file` instead of `log_dir` for logging to a single file (See `examples/log_file/usage_log_file.go`)
|
||||
- You can now use `log-file` instead of `log-dir` for logging to a single file (See `examples/log_file/usage_log_file.go`)
|
||||
- If you want to redirect everything logged using klog somewhere else (say syslog!), you can use `klog.SetOutput()` method and supply a `io.Writer`. (See `examples/set_output/usage_set_output.go`)
|
||||
- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md))
|
||||
|
||||
**NOTE**: please use the newer go versions that support semantic import versioning in modules, ideally go 1.11.4 or greater.
|
||||
|
||||
### Coexisting with glog
|
||||
This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and synchronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`.
|
||||
This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and syncronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`.
|
||||
|
||||
## Community, discussion, contribution, and support
|
||||
|
||||
@ -44,7 +42,7 @@ Learn how to engage with the Kubernetes community on the [community page](http:/
|
||||
|
||||
You can reach the maintainers of this project at:
|
||||
|
||||
- [Slack](https://kubernetes.slack.com/messages/klog)
|
||||
- [Slack](https://kubernetes.slack.com/messages/sig-architecture)
|
||||
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture)
|
||||
|
||||
### Code of conduct
|
0
vendor/k8s.io/klog/v2/RELEASE.md → vendor/k8s.io/klog/RELEASE.md
generated
vendored
0
vendor/k8s.io/klog/v2/RELEASE.md → vendor/k8s.io/klog/RELEASE.md
generated
vendored
0
vendor/k8s.io/klog/v2/SECURITY_CONTACTS → vendor/k8s.io/klog/SECURITY_CONTACTS
generated
vendored
0
vendor/k8s.io/klog/v2/SECURITY_CONTACTS → vendor/k8s.io/klog/SECURITY_CONTACTS
generated
vendored
0
vendor/k8s.io/klog/v2/code-of-conduct.md → vendor/k8s.io/klog/code-of-conduct.md
generated
vendored
0
vendor/k8s.io/klog/v2/code-of-conduct.md → vendor/k8s.io/klog/code-of-conduct.md
generated
vendored
5
vendor/k8s.io/klog/go.mod
generated
vendored
Normal file
5
vendor/k8s.io/klog/go.mod
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
module k8s.io/klog
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/go-logr/logr v0.1.0
|
2
vendor/k8s.io/klog/go.sum
generated
vendored
Normal file
2
vendor/k8s.io/klog/go.sum
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
347
vendor/k8s.io/klog/v2/klog.go → vendor/k8s.io/klog/klog.go
generated
vendored
347
vendor/k8s.io/klog/v2/klog.go → vendor/k8s.io/klog/klog.go
generated
vendored
@ -87,8 +87,6 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
)
|
||||
|
||||
// severity identifies the sort of log: info, warning etc. It also implements
|
||||
@ -132,7 +130,7 @@ func (s *severity) String() string {
|
||||
return strconv.FormatInt(int64(*s), 10)
|
||||
}
|
||||
|
||||
// Get is part of the flag.Getter interface.
|
||||
// Get is part of the flag.Value interface.
|
||||
func (s *severity) Get() interface{} {
|
||||
return *s
|
||||
}
|
||||
@ -221,7 +219,7 @@ func (l *Level) String() string {
|
||||
return strconv.FormatInt(int64(*l), 10)
|
||||
}
|
||||
|
||||
// Get is part of the flag.Getter interface.
|
||||
// Get is part of the flag.Value interface.
|
||||
func (l *Level) Get() interface{} {
|
||||
return *l
|
||||
}
|
||||
@ -366,11 +364,8 @@ var errTraceSyntax = errors.New("syntax error: expect file.go:234")
|
||||
func (t *traceLocation) Set(value string) error {
|
||||
if value == "" {
|
||||
// Unset.
|
||||
logging.mu.Lock()
|
||||
defer logging.mu.Unlock()
|
||||
t.line = 0
|
||||
t.file = ""
|
||||
return nil
|
||||
}
|
||||
fields := strings.Split(value, ":")
|
||||
if len(fields) != 2 {
|
||||
@ -430,7 +425,7 @@ func InitFlags(flagset *flag.FlagSet) {
|
||||
flagset.BoolVar(&logging.toStderr, "logtostderr", logging.toStderr, "log to standard error instead of files")
|
||||
flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", logging.alsoToStderr, "log to standard error as well as files")
|
||||
flagset.Var(&logging.verbosity, "v", "number for the log level verbosity")
|
||||
flagset.BoolVar(&logging.addDirHeader, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header of the log messages")
|
||||
flagset.BoolVar(&logging.skipHeaders, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header")
|
||||
flagset.BoolVar(&logging.skipHeaders, "skip_headers", logging.skipHeaders, "If true, avoid header prefixes in the log messages")
|
||||
flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", logging.skipLogHeaders, "If true, avoid headers when opening log files")
|
||||
flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
|
||||
@ -487,7 +482,7 @@ type loggingT struct {
|
||||
logDir string
|
||||
|
||||
// If non-empty, specifies the path of the file to write logs. mutually exclusive
|
||||
// with the log_dir option.
|
||||
// with the log-dir option.
|
||||
logFile string
|
||||
|
||||
// When logFile is specified, this limiter makes sure the logFile won't exceeds a certain size. When exceeds, the
|
||||
@ -502,9 +497,6 @@ type loggingT struct {
|
||||
|
||||
// If true, add the file directory to the header
|
||||
addDirHeader bool
|
||||
|
||||
// If set, all output will be redirected unconditionally to the provided logr.Logger
|
||||
logr logr.Logger
|
||||
}
|
||||
|
||||
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
|
||||
@ -520,20 +512,20 @@ var logging loggingT
|
||||
// l.mu is held.
|
||||
func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) {
|
||||
// Turn verbosity off so V will not fire while we are in transition.
|
||||
l.verbosity.set(0)
|
||||
logging.verbosity.set(0)
|
||||
// Ditto for filter length.
|
||||
atomic.StoreInt32(&l.filterLength, 0)
|
||||
atomic.StoreInt32(&logging.filterLength, 0)
|
||||
|
||||
// Set the new filters and wipe the pc->Level map if the filter has changed.
|
||||
if setFilter {
|
||||
l.vmodule.filter = filter
|
||||
l.vmap = make(map[uintptr]Level)
|
||||
logging.vmodule.filter = filter
|
||||
logging.vmap = make(map[uintptr]Level)
|
||||
}
|
||||
|
||||
// Things are consistent now, so enable filtering and verbosity.
|
||||
// They are enabled in order opposite to that in V.
|
||||
atomic.StoreInt32(&l.filterLength, int32(len(filter)))
|
||||
l.verbosity.set(verbosity)
|
||||
atomic.StoreInt32(&logging.filterLength, int32(len(filter)))
|
||||
logging.verbosity.set(verbosity)
|
||||
}
|
||||
|
||||
// getBuffer returns a new, ready-to-use buffer.
|
||||
@ -687,131 +679,44 @@ func (buf *buffer) someDigits(i, d int) int {
|
||||
return copy(buf.tmp[i:], buf.tmp[j:])
|
||||
}
|
||||
|
||||
func (l *loggingT) println(s severity, logr logr.Logger, args ...interface{}) {
|
||||
func (l *loggingT) println(s severity, args ...interface{}) {
|
||||
buf, file, line := l.header(s, 0)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
if logr != nil {
|
||||
l.putBuffer(buf)
|
||||
buf = l.getBuffer()
|
||||
}
|
||||
fmt.Fprintln(buf, args...)
|
||||
l.output(s, logr, buf, file, line, false)
|
||||
l.output(s, buf, file, line, false)
|
||||
}
|
||||
|
||||
func (l *loggingT) print(s severity, logr logr.Logger, args ...interface{}) {
|
||||
l.printDepth(s, logr, 1, args...)
|
||||
func (l *loggingT) print(s severity, args ...interface{}) {
|
||||
l.printDepth(s, 1, args...)
|
||||
}
|
||||
|
||||
func (l *loggingT) printDepth(s severity, logr logr.Logger, depth int, args ...interface{}) {
|
||||
func (l *loggingT) printDepth(s severity, depth int, args ...interface{}) {
|
||||
buf, file, line := l.header(s, depth)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
if logr != nil {
|
||||
l.putBuffer(buf)
|
||||
buf = l.getBuffer()
|
||||
}
|
||||
fmt.Fprint(buf, args...)
|
||||
if buf.Bytes()[buf.Len()-1] != '\n' {
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
l.output(s, logr, buf, file, line, false)
|
||||
l.output(s, buf, file, line, false)
|
||||
}
|
||||
|
||||
func (l *loggingT) printf(s severity, logr logr.Logger, format string, args ...interface{}) {
|
||||
func (l *loggingT) printf(s severity, format string, args ...interface{}) {
|
||||
buf, file, line := l.header(s, 0)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
if logr != nil {
|
||||
l.putBuffer(buf)
|
||||
buf = l.getBuffer()
|
||||
}
|
||||
fmt.Fprintf(buf, format, args...)
|
||||
if buf.Bytes()[buf.Len()-1] != '\n' {
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
l.output(s, logr, buf, file, line, false)
|
||||
l.output(s, buf, file, line, false)
|
||||
}
|
||||
|
||||
// printWithFileLine behaves like print but uses the provided file and line number. If
|
||||
// alsoLogToStderr is true, the log message always appears on standard error; it
|
||||
// will also appear in the log file unless --logtostderr is set.
|
||||
func (l *loggingT) printWithFileLine(s severity, logr logr.Logger, file string, line int, alsoToStderr bool, args ...interface{}) {
|
||||
func (l *loggingT) printWithFileLine(s severity, file string, line int, alsoToStderr bool, args ...interface{}) {
|
||||
buf := l.formatHeader(s, file, line)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
if logr != nil {
|
||||
l.putBuffer(buf)
|
||||
buf = l.getBuffer()
|
||||
}
|
||||
fmt.Fprint(buf, args...)
|
||||
if buf.Bytes()[buf.Len()-1] != '\n' {
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
l.output(s, logr, buf, file, line, alsoToStderr)
|
||||
}
|
||||
|
||||
// if loggr is specified, will call loggr.Error, otherwise output with logging module.
|
||||
func (l *loggingT) errorS(err error, loggr logr.Logger, msg string, keysAndValues ...interface{}) {
|
||||
if loggr != nil {
|
||||
loggr.Error(err, msg, keysAndValues)
|
||||
return
|
||||
}
|
||||
l.printS(err, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// if loggr is specified, will call loggr.Info, otherwise output with logging module.
|
||||
func (l *loggingT) infoS(loggr logr.Logger, msg string, keysAndValues ...interface{}) {
|
||||
if loggr != nil {
|
||||
loggr.Info(msg, keysAndValues)
|
||||
return
|
||||
}
|
||||
l.printS(nil, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// printS is called from infoS and errorS if loggr is not specified.
|
||||
// if err arguments is specified, will output to errorLog severity
|
||||
func (l *loggingT) printS(err error, msg string, keysAndValues ...interface{}) {
|
||||
b := &bytes.Buffer{}
|
||||
b.WriteString(fmt.Sprintf("%q", msg))
|
||||
if err != nil {
|
||||
b.WriteByte(' ')
|
||||
b.WriteString(fmt.Sprintf("err=%q", err.Error()))
|
||||
}
|
||||
kvListFormat(b, keysAndValues...)
|
||||
var s severity
|
||||
if err == nil {
|
||||
s = infoLog
|
||||
} else {
|
||||
s = errorLog
|
||||
}
|
||||
l.printDepth(s, logging.logr, 2, b)
|
||||
}
|
||||
|
||||
const missingValue = "(MISSING)"
|
||||
|
||||
func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) {
|
||||
for i := 0; i < len(keysAndValues); i += 2 {
|
||||
var v interface{}
|
||||
k := keysAndValues[i]
|
||||
if i+1 < len(keysAndValues) {
|
||||
v = keysAndValues[i+1]
|
||||
} else {
|
||||
v = missingValue
|
||||
}
|
||||
b.WriteByte(' ')
|
||||
|
||||
switch v.(type) {
|
||||
case string, error:
|
||||
b.WriteString(fmt.Sprintf("%s=%q", k, v))
|
||||
default:
|
||||
if _, ok := v.(fmt.Stringer); ok {
|
||||
b.WriteString(fmt.Sprintf("%s=%q", k, v))
|
||||
} else {
|
||||
b.WriteString(fmt.Sprintf("%s=%+v", k, v))
|
||||
}
|
||||
}
|
||||
}
|
||||
l.output(s, buf, file, line, alsoToStderr)
|
||||
}
|
||||
|
||||
// redirectBuffer is used to set an alternate destination for the logs
|
||||
@ -831,18 +736,6 @@ func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
|
||||
return rb.w.Write(bytes)
|
||||
}
|
||||
|
||||
// SetLogger will set the backing logr implementation for klog.
|
||||
// If set, all log lines will be suppressed from the regular Output, and
|
||||
// redirected to the logr implementation.
|
||||
// All log lines include the 'severity', 'file' and 'line' values attached as
|
||||
// structured logging values.
|
||||
// Use as:
|
||||
// ...
|
||||
// klog.SetLogger(zapr.NewLogger(zapLog))
|
||||
func SetLogger(logr logr.Logger) {
|
||||
logging.logr = logr
|
||||
}
|
||||
|
||||
// SetOutput sets the output destination for all severities
|
||||
func SetOutput(w io.Writer) {
|
||||
logging.mu.Lock()
|
||||
@ -869,16 +762,8 @@ func SetOutputBySeverity(name string, w io.Writer) {
|
||||
logging.file[sev] = rb
|
||||
}
|
||||
|
||||
// LogToStderr sets whether to log exclusively to stderr, bypassing outputs
|
||||
func LogToStderr(stderr bool) {
|
||||
logging.mu.Lock()
|
||||
defer logging.mu.Unlock()
|
||||
|
||||
logging.toStderr = stderr
|
||||
}
|
||||
|
||||
// output writes the data to the log files and releases the buffer.
|
||||
func (l *loggingT) output(s severity, log logr.Logger, buf *buffer, file string, line int, alsoToStderr bool) {
|
||||
func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoToStderr bool) {
|
||||
l.mu.Lock()
|
||||
if l.traceLocation.isSet() {
|
||||
if l.traceLocation.match(file, line) {
|
||||
@ -886,15 +771,7 @@ func (l *loggingT) output(s severity, log logr.Logger, buf *buffer, file string,
|
||||
}
|
||||
}
|
||||
data := buf.Bytes()
|
||||
if log != nil {
|
||||
// TODO: set 'severity' and caller information as structured log info
|
||||
// keysAndValues := []interface{}{"severity", severityName[s], "file", file, "line", line}
|
||||
if s == errorLog {
|
||||
l.logr.Error(nil, string(data))
|
||||
} else {
|
||||
log.Info(string(data))
|
||||
}
|
||||
} else if l.toStderr {
|
||||
if l.toStderr {
|
||||
os.Stderr.Write(data)
|
||||
} else {
|
||||
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
|
||||
@ -942,12 +819,14 @@ func (l *loggingT) output(s severity, log logr.Logger, buf *buffer, file string,
|
||||
os.Exit(1)
|
||||
}
|
||||
// Dump all goroutine stacks before exiting.
|
||||
trace := stacks(true)
|
||||
// Write the stack trace for all goroutines to the stderr.
|
||||
if l.toStderr || l.alsoToStderr || s >= l.stderrThreshold.get() || alsoToStderr {
|
||||
os.Stderr.Write(trace)
|
||||
// First, make sure we see the trace for the current goroutine on standard error.
|
||||
// If -logtostderr has been specified, the loop below will do that anyway
|
||||
// as the first stack in the full dump.
|
||||
if !l.toStderr {
|
||||
os.Stderr.Write(stacks(false))
|
||||
}
|
||||
// Write the stack trace for all goroutines to the files.
|
||||
trace := stacks(true)
|
||||
logExitFunc = func(error) {} // If we get a write error, we'll still exit below.
|
||||
for log := fatalLog; log >= infoLog; log-- {
|
||||
if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set.
|
||||
@ -1197,7 +1076,7 @@ func (lb logBridge) Write(b []byte) (n int, err error) {
|
||||
}
|
||||
// printWithFileLine with alsoToStderr=true, so standard log messages
|
||||
// always appear on standard error.
|
||||
logging.printWithFileLine(severity(lb), logging.logr, file, line, true, text)
|
||||
logging.printWithFileLine(severity(lb), file, line, true, text)
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
@ -1229,40 +1108,29 @@ func (l *loggingT) setV(pc uintptr) Level {
|
||||
|
||||
// Verbose is a boolean type that implements Infof (like Printf) etc.
|
||||
// See the documentation of V for more information.
|
||||
type Verbose struct {
|
||||
enabled bool
|
||||
logr logr.Logger
|
||||
}
|
||||
|
||||
func newVerbose(level Level, b bool) Verbose {
|
||||
if logging.logr == nil {
|
||||
return Verbose{b, nil}
|
||||
}
|
||||
return Verbose{b, logging.logr.V(int(level))}
|
||||
}
|
||||
type Verbose bool
|
||||
|
||||
// V reports whether verbosity at the call site is at least the requested level.
|
||||
// The returned value is a struct of type Verbose, which implements Info, Infoln
|
||||
// The returned value is a boolean of type Verbose, which implements Info, Infoln
|
||||
// and Infof. These methods will write to the Info log if called.
|
||||
// Thus, one may write either
|
||||
// if glog.V(2).Enabled() { klog.Info("log this") }
|
||||
// if klog.V(2) { klog.Info("log this") }
|
||||
// or
|
||||
// klog.V(2).Info("log this")
|
||||
// The second form is shorter but the first is cheaper if logging is off because it does
|
||||
// not evaluate its arguments.
|
||||
//
|
||||
// Whether an individual call to V generates a log record depends on the setting of
|
||||
// the -v and -vmodule flags; both are off by default. The V call will log if its level
|
||||
// is less than or equal to the value of the -v flag, or alternatively if its level is
|
||||
// less than or equal to the value of the -vmodule pattern matching the source file
|
||||
// containing the call.
|
||||
// the -v and --vmodule flags; both are off by default. If the level in the call to
|
||||
// V is at least the value of -v, or of -vmodule for the source file containing the
|
||||
// call, the V call will log.
|
||||
func V(level Level) Verbose {
|
||||
// This function tries hard to be cheap unless there's work to do.
|
||||
// The fast path is two atomic loads and compares.
|
||||
|
||||
// Here is a cheap but safe test to see if V logging is enabled globally.
|
||||
if logging.verbosity.get() >= level {
|
||||
return newVerbose(level, true)
|
||||
return Verbose(true)
|
||||
}
|
||||
|
||||
// It's off globally but it vmodule may still be set.
|
||||
@ -1274,186 +1142,138 @@ func V(level Level) Verbose {
|
||||
logging.mu.Lock()
|
||||
defer logging.mu.Unlock()
|
||||
if runtime.Callers(2, logging.pcs[:]) == 0 {
|
||||
return newVerbose(level, false)
|
||||
return Verbose(false)
|
||||
}
|
||||
v, ok := logging.vmap[logging.pcs[0]]
|
||||
if !ok {
|
||||
v = logging.setV(logging.pcs[0])
|
||||
}
|
||||
return newVerbose(level, v >= level)
|
||||
return Verbose(v >= level)
|
||||
}
|
||||
return newVerbose(level, false)
|
||||
}
|
||||
|
||||
// Enabled will return true if this log level is enabled, guarded by the value
|
||||
// of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Enabled() bool {
|
||||
return v.enabled
|
||||
return Verbose(false)
|
||||
}
|
||||
|
||||
// Info is equivalent to the global Info function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Info(args ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.print(infoLog, v.logr, args...)
|
||||
if v {
|
||||
logging.print(infoLog, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Infoln is equivalent to the global Infoln function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Infoln(args ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.println(infoLog, v.logr, args...)
|
||||
if v {
|
||||
logging.println(infoLog, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Infof is equivalent to the global Infof function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Infof(format string, args ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.printf(infoLog, v.logr, format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// InfoS is equivalent to the global InfoS function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) InfoS(msg string, keysAndValues ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.infoS(v.logr, msg, keysAndValues...)
|
||||
}
|
||||
}
|
||||
|
||||
// Error is equivalent to the global Error function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Error(err error, msg string, args ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.errorS(err, v.logr, msg, args...)
|
||||
if v {
|
||||
logging.printf(infoLog, format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// Info logs to the INFO log.
|
||||
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
||||
func Info(args ...interface{}) {
|
||||
logging.print(infoLog, logging.logr, args...)
|
||||
logging.print(infoLog, args...)
|
||||
}
|
||||
|
||||
// InfoDepth acts as Info but uses depth to determine which call frame to log.
|
||||
// InfoDepth(0, "msg") is the same as Info("msg").
|
||||
func InfoDepth(depth int, args ...interface{}) {
|
||||
logging.printDepth(infoLog, logging.logr, depth, args...)
|
||||
logging.printDepth(infoLog, depth, args...)
|
||||
}
|
||||
|
||||
// Infoln logs to the INFO log.
|
||||
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
|
||||
func Infoln(args ...interface{}) {
|
||||
logging.println(infoLog, logging.logr, args...)
|
||||
logging.println(infoLog, args...)
|
||||
}
|
||||
|
||||
// Infof logs to the INFO log.
|
||||
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
|
||||
func Infof(format string, args ...interface{}) {
|
||||
logging.printf(infoLog, logging.logr, format, args...)
|
||||
}
|
||||
|
||||
// InfoS structured logs to the INFO log.
|
||||
// The msg argument used to add constant description to the log line.
|
||||
// The key/value pairs would be join by "=" ; a newline is always appended.
|
||||
//
|
||||
// Basic examples:
|
||||
// >> klog.InfoS("Pod status updated", "pod", "kubedns", "status", "ready")
|
||||
// output:
|
||||
// >> I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kubedns" status="ready"
|
||||
func InfoS(msg string, keysAndValues ...interface{}) {
|
||||
logging.infoS(logging.logr, msg, keysAndValues...)
|
||||
logging.printf(infoLog, format, args...)
|
||||
}
|
||||
|
||||
// Warning logs to the WARNING and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
||||
func Warning(args ...interface{}) {
|
||||
logging.print(warningLog, logging.logr, args...)
|
||||
logging.print(warningLog, args...)
|
||||
}
|
||||
|
||||
// WarningDepth acts as Warning but uses depth to determine which call frame to log.
|
||||
// WarningDepth(0, "msg") is the same as Warning("msg").
|
||||
func WarningDepth(depth int, args ...interface{}) {
|
||||
logging.printDepth(warningLog, logging.logr, depth, args...)
|
||||
logging.printDepth(warningLog, depth, args...)
|
||||
}
|
||||
|
||||
// Warningln logs to the WARNING and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
|
||||
func Warningln(args ...interface{}) {
|
||||
logging.println(warningLog, logging.logr, args...)
|
||||
logging.println(warningLog, args...)
|
||||
}
|
||||
|
||||
// Warningf logs to the WARNING and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
|
||||
func Warningf(format string, args ...interface{}) {
|
||||
logging.printf(warningLog, logging.logr, format, args...)
|
||||
logging.printf(warningLog, format, args...)
|
||||
}
|
||||
|
||||
// Error logs to the ERROR, WARNING, and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
||||
func Error(args ...interface{}) {
|
||||
logging.print(errorLog, logging.logr, args...)
|
||||
logging.print(errorLog, args...)
|
||||
}
|
||||
|
||||
// ErrorDepth acts as Error but uses depth to determine which call frame to log.
|
||||
// ErrorDepth(0, "msg") is the same as Error("msg").
|
||||
func ErrorDepth(depth int, args ...interface{}) {
|
||||
logging.printDepth(errorLog, logging.logr, depth, args...)
|
||||
logging.printDepth(errorLog, depth, args...)
|
||||
}
|
||||
|
||||
// Errorln logs to the ERROR, WARNING, and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
|
||||
func Errorln(args ...interface{}) {
|
||||
logging.println(errorLog, logging.logr, args...)
|
||||
logging.println(errorLog, args...)
|
||||
}
|
||||
|
||||
// Errorf logs to the ERROR, WARNING, and INFO logs.
|
||||
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
logging.printf(errorLog, logging.logr, format, args...)
|
||||
}
|
||||
|
||||
// ErrorS structured logs to the ERROR, WARNING, and INFO logs.
|
||||
// the err argument used as "err" field of log line.
|
||||
// The msg argument used to add constant description to the log line.
|
||||
// The key/value pairs would be join by "=" ; a newline is always appended.
|
||||
//
|
||||
// Basic examples:
|
||||
// >> klog.ErrorS(err, "Failed to update pod status")
|
||||
// output:
|
||||
// >> E1025 00:15:15.525108 1 controller_utils.go:114] "Failed to update pod status" err="timeout"
|
||||
func ErrorS(err error, msg string, keysAndValues ...interface{}) {
|
||||
logging.errorS(err, logging.logr, msg, keysAndValues...)
|
||||
logging.printf(errorLog, format, args...)
|
||||
}
|
||||
|
||||
// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs,
|
||||
// including a stack trace of all running goroutines, then calls os.Exit(255).
|
||||
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
||||
func Fatal(args ...interface{}) {
|
||||
logging.print(fatalLog, logging.logr, args...)
|
||||
logging.print(fatalLog, args...)
|
||||
}
|
||||
|
||||
// FatalDepth acts as Fatal but uses depth to determine which call frame to log.
|
||||
// FatalDepth(0, "msg") is the same as Fatal("msg").
|
||||
func FatalDepth(depth int, args ...interface{}) {
|
||||
logging.printDepth(fatalLog, logging.logr, depth, args...)
|
||||
logging.printDepth(fatalLog, depth, args...)
|
||||
}
|
||||
|
||||
// Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs,
|
||||
// including a stack trace of all running goroutines, then calls os.Exit(255).
|
||||
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
|
||||
func Fatalln(args ...interface{}) {
|
||||
logging.println(fatalLog, logging.logr, args...)
|
||||
logging.println(fatalLog, args...)
|
||||
}
|
||||
|
||||
// Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs,
|
||||
// including a stack trace of all running goroutines, then calls os.Exit(255).
|
||||
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
logging.printf(fatalLog, logging.logr, format, args...)
|
||||
logging.printf(fatalLog, format, args...)
|
||||
}
|
||||
|
||||
// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks.
|
||||
@ -1464,62 +1284,25 @@ var fatalNoStacks uint32
|
||||
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
||||
func Exit(args ...interface{}) {
|
||||
atomic.StoreUint32(&fatalNoStacks, 1)
|
||||
logging.print(fatalLog, logging.logr, args...)
|
||||
logging.print(fatalLog, args...)
|
||||
}
|
||||
|
||||
// ExitDepth acts as Exit but uses depth to determine which call frame to log.
|
||||
// ExitDepth(0, "msg") is the same as Exit("msg").
|
||||
func ExitDepth(depth int, args ...interface{}) {
|
||||
atomic.StoreUint32(&fatalNoStacks, 1)
|
||||
logging.printDepth(fatalLog, logging.logr, depth, args...)
|
||||
logging.printDepth(fatalLog, depth, args...)
|
||||
}
|
||||
|
||||
// Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
|
||||
func Exitln(args ...interface{}) {
|
||||
atomic.StoreUint32(&fatalNoStacks, 1)
|
||||
logging.println(fatalLog, logging.logr, args...)
|
||||
logging.println(fatalLog, args...)
|
||||
}
|
||||
|
||||
// Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
|
||||
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
|
||||
func Exitf(format string, args ...interface{}) {
|
||||
atomic.StoreUint32(&fatalNoStacks, 1)
|
||||
logging.printf(fatalLog, logging.logr, format, args...)
|
||||
}
|
||||
|
||||
// ObjectRef references a kubernetes object
|
||||
type ObjectRef struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
}
|
||||
|
||||
func (ref ObjectRef) String() string {
|
||||
if ref.Namespace != "" {
|
||||
return fmt.Sprintf("%s/%s", ref.Namespace, ref.Name)
|
||||
}
|
||||
return ref.Name
|
||||
}
|
||||
|
||||
// KMetadata is a subset of the kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface
|
||||
// this interface may expand in the future, but will always be a subset of the
|
||||
// kubernetes k8s.io/apimachinery/pkg/apis/meta/v1.Object interface
|
||||
type KMetadata interface {
|
||||
GetName() string
|
||||
GetNamespace() string
|
||||
}
|
||||
|
||||
// KObj returns ObjectRef from ObjectMeta
|
||||
func KObj(obj KMetadata) ObjectRef {
|
||||
return ObjectRef{
|
||||
Name: obj.GetName(),
|
||||
Namespace: obj.GetNamespace(),
|
||||
}
|
||||
}
|
||||
|
||||
// KRef returns ObjectRef from name and namespace
|
||||
func KRef(namespace, name string) ObjectRef {
|
||||
return ObjectRef{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
}
|
||||
logging.printf(fatalLog, format, args...)
|
||||
}
|
51
vendor/k8s.io/klog/v2/klog_file.go → vendor/k8s.io/klog/klog_file.go
generated
vendored
51
vendor/k8s.io/klog/v2/klog_file.go → vendor/k8s.io/klog/klog_file.go
generated
vendored
@ -24,7 +24,6 @@ import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -44,49 +43,25 @@ func createLogDirs() {
|
||||
}
|
||||
|
||||
var (
|
||||
pid = os.Getpid()
|
||||
program = filepath.Base(os.Args[0])
|
||||
host = "unknownhost"
|
||||
userName = "unknownuser"
|
||||
userNameOnce sync.Once
|
||||
pid = os.Getpid()
|
||||
program = filepath.Base(os.Args[0])
|
||||
host = "unknownhost"
|
||||
userName = "unknownuser"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if h, err := os.Hostname(); err == nil {
|
||||
h, err := os.Hostname()
|
||||
if err == nil {
|
||||
host = shortHostname(h)
|
||||
}
|
||||
}
|
||||
|
||||
func getUserName() string {
|
||||
userNameOnce.Do(func() {
|
||||
// On Windows, the Go 'user' package requires netapi32.dll.
|
||||
// This affects Windows Nano Server:
|
||||
// https://github.com/golang/go/issues/21867
|
||||
// Fallback to using environment variables.
|
||||
if runtime.GOOS == "windows" {
|
||||
u := os.Getenv("USERNAME")
|
||||
if len(u) == 0 {
|
||||
return
|
||||
}
|
||||
// Sanitize the USERNAME since it may contain filepath separators.
|
||||
u = strings.Replace(u, `\`, "_", -1)
|
||||
current, err := user.Current()
|
||||
if err == nil {
|
||||
userName = current.Username
|
||||
}
|
||||
|
||||
// user.Current().Username normally produces something like 'USERDOMAIN\USERNAME'
|
||||
d := os.Getenv("USERDOMAIN")
|
||||
if len(d) != 0 {
|
||||
userName = d + "_" + u
|
||||
} else {
|
||||
userName = u
|
||||
}
|
||||
} else {
|
||||
current, err := user.Current()
|
||||
if err == nil {
|
||||
userName = current.Username
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return userName
|
||||
// Sanitize userName since it may contain filepath separators on Windows.
|
||||
userName = strings.Replace(userName, `\`, "_", -1)
|
||||
}
|
||||
|
||||
// shortHostname returns its argument, truncating at the first period.
|
||||
@ -104,7 +79,7 @@ func logName(tag string, t time.Time) (name, link string) {
|
||||
name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d",
|
||||
program,
|
||||
host,
|
||||
getUserName(),
|
||||
userName,
|
||||
tag,
|
||||
t.Year(),
|
||||
t.Month(),
|
17
vendor/k8s.io/klog/v2/.gitignore
generated
vendored
17
vendor/k8s.io/klog/v2/.gitignore
generated
vendored
@ -1,17 +0,0 @@
|
||||
# OSX leaves these everywhere on SMB shares
|
||||
._*
|
||||
|
||||
# OSX trash
|
||||
.DS_Store
|
||||
|
||||
# Eclipse files
|
||||
.classpath
|
||||
.project
|
||||
.settings/**
|
||||
|
||||
# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
|
||||
.idea/
|
||||
*.iml
|
||||
|
||||
# Vscode files
|
||||
.vscode
|
5
vendor/k8s.io/klog/v2/go.mod
generated
vendored
5
vendor/k8s.io/klog/v2/go.mod
generated
vendored
@ -1,5 +0,0 @@
|
||||
module k8s.io/klog/v2
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/go-logr/logr v0.2.0
|
2
vendor/k8s.io/klog/v2/go.sum
generated
vendored
2
vendor/k8s.io/klog/v2/go.sum
generated
vendored
@ -1,2 +0,0 @@
|
||||
github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY=
|
||||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
Reference in New Issue
Block a user