summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/klog
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2020-01-14 14:46:46 -0500
committerTomSweeneyRedHat <tsweeney@redhat.com>2020-01-14 14:46:46 -0500
commitf5bda9994d5e6cb1ee42ade5e7786059feedf633 (patch)
tree4473a0c3b4615ee58165f06ccf57a1bfe4298fe9 /vendor/k8s.io/klog
parent564bd693cae4e8a870be7a7860ef673e793f6358 (diff)
downloadpodman-f5bda9994d5e6cb1ee42ade5e7786059feedf633.tar.gz
podman-f5bda9994d5e6cb1ee42ade5e7786059feedf633.tar.bz2
podman-f5bda9994d5e6cb1ee42ade5e7786059feedf633.zip
Bump to Buildah v1.13.1
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'vendor/k8s.io/klog')
-rw-r--r--vendor/k8s.io/klog/.travis.yml3
-rw-r--r--vendor/k8s.io/klog/README.md2
-rw-r--r--vendor/k8s.io/klog/go.mod5
-rw-r--r--vendor/k8s.io/klog/go.sum2
-rw-r--r--vendor/k8s.io/klog/klog.go124
5 files changed, 82 insertions, 54 deletions
diff --git a/vendor/k8s.io/klog/.travis.yml b/vendor/k8s.io/klog/.travis.yml
index 0f508dae6..5677664c2 100644
--- a/vendor/k8s.io/klog/.travis.yml
+++ b/vendor/k8s.io/klog/.travis.yml
@@ -5,11 +5,12 @@ 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 tool vet . || go vet .
- go test -v -race ./...
install:
- go get golang.org/x/lint/golint
diff --git a/vendor/k8s.io/klog/README.md b/vendor/k8s.io/klog/README.md
index bee306f39..841468b4b 100644
--- a/vendor/k8s.io/klog/README.md
+++ b/vendor/k8s.io/klog/README.md
@@ -31,7 +31,7 @@ How to use 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`)
- 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/logging.md))
+- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md))
### 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 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`.
diff --git a/vendor/k8s.io/klog/go.mod b/vendor/k8s.io/klog/go.mod
new file mode 100644
index 000000000..3877d8546
--- /dev/null
+++ b/vendor/k8s.io/klog/go.mod
@@ -0,0 +1,5 @@
+module k8s.io/klog
+
+go 1.12
+
+require github.com/go-logr/logr v0.1.0
diff --git a/vendor/k8s.io/klog/go.sum b/vendor/k8s.io/klog/go.sum
new file mode 100644
index 000000000..fb64d277a
--- /dev/null
+++ b/vendor/k8s.io/klog/go.sum
@@ -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=
diff --git a/vendor/k8s.io/klog/klog.go b/vendor/k8s.io/klog/klog.go
index 10330d7ef..2712ce0af 100644
--- a/vendor/k8s.io/klog/klog.go
+++ b/vendor/k8s.io/klog/klog.go
@@ -20,17 +20,17 @@
//
// Basic examples:
//
-// glog.Info("Prepare to repel boarders")
+// klog.Info("Prepare to repel boarders")
//
-// glog.Fatalf("Initialization failed: %s", err)
+// klog.Fatalf("Initialization failed: %s", err)
//
// See the documentation for the V function for an explanation of these examples:
//
-// if glog.V(2) {
-// glog.Info("Starting transaction...")
+// if klog.V(2) {
+// klog.Info("Starting transaction...")
// }
//
-// glog.V(2).Infoln("Processed", nItems, "elements")
+// klog.V(2).Infoln("Processed", nItems, "elements")
//
// Log output is buffered and written periodically using Flush. Programs
// should call Flush before exiting to guarantee all log output is written.
@@ -142,7 +142,7 @@ func (s *severity) Set(value string) error {
if v, ok := severityByName(value); ok {
threshold = v
} else {
- v, err := strconv.Atoi(value)
+ v, err := strconv.ParseInt(value, 10, 32)
if err != nil {
return err
}
@@ -226,7 +226,7 @@ func (l *Level) Get() interface{} {
// Set is part of the flag.Value interface.
func (l *Level) Set(value string) error {
- v, err := strconv.Atoi(value)
+ v, err := strconv.ParseInt(value, 10, 32)
if err != nil {
return err
}
@@ -294,7 +294,7 @@ func (m *moduleSpec) Set(value string) error {
return errVmoduleSyntax
}
pattern := patLev[0]
- v, err := strconv.Atoi(patLev[1])
+ v, err := strconv.ParseInt(patLev[1], 10, 32)
if err != nil {
return errors.New("syntax error: expect comma-separated list of filename=N")
}
@@ -396,30 +396,23 @@ type flushSyncWriter interface {
io.Writer
}
+// init sets up the defaults and runs flushDaemon.
func init() {
- // Default stderrThreshold is ERROR.
- logging.stderrThreshold = errorLog
-
+ logging.stderrThreshold = errorLog // Default stderrThreshold is ERROR.
logging.setVState(0, nil, false)
+ logging.logDir = ""
+ logging.logFile = ""
+ logging.logFileMaxSizeMB = 1800
+ logging.toStderr = true
+ logging.alsoToStderr = false
+ logging.skipHeaders = false
+ logging.addDirHeader = false
+ logging.skipLogHeaders = false
go logging.flushDaemon()
}
-var initDefaultsOnce sync.Once
-
// InitFlags is for explicitly initializing the flags.
func InitFlags(flagset *flag.FlagSet) {
-
- // Initialize defaults.
- initDefaultsOnce.Do(func() {
- logging.logDir = ""
- logging.logFile = ""
- logging.logFileMaxSizeMB = 1800
- logging.toStderr = true
- logging.alsoToStderr = false
- logging.skipHeaders = false
- logging.skipLogHeaders = false
- })
-
if flagset == nil {
flagset = flag.CommandLine
}
@@ -432,6 +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.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")
@@ -500,6 +494,9 @@ type loggingT struct {
// If true, do not add the headers to log files
skipLogHeaders bool
+
+ // If true, add the file directory to the header
+ addDirHeader bool
}
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
@@ -585,9 +582,14 @@ func (l *loggingT) header(s severity, depth int) (*buffer, string, int) {
file = "???"
line = 1
} else {
- slash := strings.LastIndex(file, "/")
- if slash >= 0 {
- file = file[slash+1:]
+ if slash := strings.LastIndex(file, "/"); slash >= 0 {
+ path := file
+ file = path[slash+1:]
+ if l.addDirHeader {
+ if dirsep := strings.LastIndex(path[:slash], "/"); dirsep >= 0 {
+ file = path[dirsep+1:]
+ }
+ }
}
}
return l.formatHeader(s, file, line), file, line
@@ -736,6 +738,8 @@ func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
// SetOutput sets the output destination for all severities
func SetOutput(w io.Writer) {
+ logging.mu.Lock()
+ defer logging.mu.Unlock()
for s := fatalLog; s >= infoLog; s-- {
rb := &redirectBuffer{
w: w,
@@ -746,6 +750,8 @@ func SetOutput(w io.Writer) {
// SetOutputBySeverity sets the output destination for specific severity
func SetOutputBySeverity(name string, w io.Writer) {
+ logging.mu.Lock()
+ defer logging.mu.Unlock()
sev, ok := severityByName(name)
if !ok {
panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name))
@@ -771,24 +777,38 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
os.Stderr.Write(data)
}
- if l.file[s] == nil {
- if err := l.createFiles(s); err != nil {
- os.Stderr.Write(data) // Make sure the message appears somewhere.
- l.exit(err)
+
+ if logging.logFile != "" {
+ // Since we are using a single log file, all of the items in l.file array
+ // will point to the same file, so just use one of them to write data.
+ if l.file[infoLog] == nil {
+ if err := l.createFiles(infoLog); err != nil {
+ os.Stderr.Write(data) // Make sure the message appears somewhere.
+ l.exit(err)
+ }
}
- }
- switch s {
- case fatalLog:
- l.file[fatalLog].Write(data)
- fallthrough
- case errorLog:
- l.file[errorLog].Write(data)
- fallthrough
- case warningLog:
- l.file[warningLog].Write(data)
- fallthrough
- case infoLog:
l.file[infoLog].Write(data)
+ } else {
+ if l.file[s] == nil {
+ if err := l.createFiles(s); err != nil {
+ os.Stderr.Write(data) // Make sure the message appears somewhere.
+ l.exit(err)
+ }
+ }
+
+ switch s {
+ case fatalLog:
+ l.file[fatalLog].Write(data)
+ fallthrough
+ case errorLog:
+ l.file[errorLog].Write(data)
+ fallthrough
+ case warningLog:
+ l.file[warningLog].Write(data)
+ fallthrough
+ case infoLog:
+ l.file[infoLog].Write(data)
+ }
}
}
if s == fatalLog {
@@ -827,7 +847,7 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
// timeoutFlush calls Flush and returns when it completes or after timeout
// elapses, whichever happens first. This is needed because the hooks invoked
-// by Flush may deadlock when glog.Fatal is called from a hook that holds
+// by Flush may deadlock when klog.Fatal is called from a hook that holds
// a lock.
func timeoutFlush(timeout time.Duration) {
done := make(chan bool, 1)
@@ -838,7 +858,7 @@ func timeoutFlush(timeout time.Duration) {
select {
case <-done:
case <-time.After(timeout):
- fmt.Fprintln(os.Stderr, "glog: Flush took longer than", timeout)
+ fmt.Fprintln(os.Stderr, "klog: Flush took longer than", timeout)
}
}
@@ -1094,9 +1114,9 @@ type Verbose bool
// 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) { glog.Info("log this") }
+// if klog.V(2) { klog.Info("log this") }
// or
-// glog.V(2).Info("log this")
+// 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.
//
@@ -1170,7 +1190,7 @@ func InfoDepth(depth int, args ...interface{}) {
}
// Infoln logs to the INFO log.
-// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
+// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Infoln(args ...interface{}) {
logging.println(infoLog, args...)
}
@@ -1194,7 +1214,7 @@ func WarningDepth(depth int, args ...interface{}) {
}
// Warningln logs to the WARNING and INFO logs.
-// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
+// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Warningln(args ...interface{}) {
logging.println(warningLog, args...)
}
@@ -1218,7 +1238,7 @@ func ErrorDepth(depth int, args ...interface{}) {
}
// Errorln logs to the ERROR, WARNING, and INFO logs.
-// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
+// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Errorln(args ...interface{}) {
logging.println(errorLog, args...)
}
@@ -1244,7 +1264,7 @@ func FatalDepth(depth int, args ...interface{}) {
// 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 appended if missing.
+// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Fatalln(args ...interface{}) {
logging.println(fatalLog, args...)
}