Switch to go modules
This commit is contained in:
parent
461954facb
commit
1720059244
763 changed files with 24896 additions and 177398 deletions
10
vendor/k8s.io/klog/OWNERS
generated
vendored
10
vendor/k8s.io/klog/OWNERS
generated
vendored
|
|
@ -1,5 +1,13 @@
|
|||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- jayunit100
|
||||
- hoegaarden
|
||||
- andyxning
|
||||
- neolit123
|
||||
- pohly
|
||||
- yagonobre
|
||||
- vincepri
|
||||
- detiber
|
||||
approvers:
|
||||
- dims
|
||||
- thockin
|
||||
|
|
|
|||
22
vendor/k8s.io/klog/README.md
generated
vendored
22
vendor/k8s.io/klog/README.md
generated
vendored
|
|
@ -1,7 +1,27 @@
|
|||
klog
|
||||
====
|
||||
|
||||
klog is a permanant fork of https://github.com/golang/glog. original README from glog is below
|
||||
klog is a permanent fork of https://github.com/golang/glog.
|
||||
|
||||
## Why was klog created?
|
||||
|
||||
The decision to create klog was one that wasn't made lightly, but it was necessary due to some
|
||||
drawbacks that are present in [glog](https://github.com/golang/glog). Ultimately, the fork was created due to glog not being under active development; this can be seen in the glog README:
|
||||
|
||||
> The code in this repo [...] is not itself under development
|
||||
|
||||
This makes us unable to solve many use cases without a fork. The factors that contributed to needing feature development are listed below:
|
||||
|
||||
* `glog` [presents a lot "gotchas"](https://github.com/kubernetes/kubernetes/issues/61006) and introduces challenges in containerized environments, all of which aren't well documented.
|
||||
* `glog` doesn't provide an easy way to test logs, which detracts from the stability of software using it
|
||||
* A long term goal is to implement a logging interface that allows us to add context, change output format, etc.
|
||||
|
||||
Historical context is available here:
|
||||
|
||||
* https://github.com/kubernetes/kubernetes/issues/61006
|
||||
* https://github.com/kubernetes/kubernetes/issues/70264
|
||||
* https://groups.google.com/forum/#!msg/kubernetes-sig-architecture/wCWiWf3Juzs/hXRVBH90CgAJ
|
||||
* https://groups.google.com/forum/#!msg/kubernetes-dev/7vnijOMhLS0/1oRiNtigBgAJ
|
||||
|
||||
----
|
||||
|
||||
|
|
|
|||
4
vendor/k8s.io/klog/SECURITY_CONTACTS
generated
vendored
4
vendor/k8s.io/klog/SECURITY_CONTACTS
generated
vendored
|
|
@ -1,10 +1,10 @@
|
|||
# Defined below are the security contacts for this repo.
|
||||
#
|
||||
# They are the contact point for the Product Security Team to reach out
|
||||
# They are the contact point for the Product Security Committee to reach out
|
||||
# to for triaging and handling of incoming issues.
|
||||
#
|
||||
# The below names agree to abide by the
|
||||
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
|
||||
# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
|
||||
# and will be removed and replaced if they violate that agreement.
|
||||
#
|
||||
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
|
||||
|
|
|
|||
64
vendor/k8s.io/klog/klog.go
generated
vendored
64
vendor/k8s.io/klog/klog.go
generated
vendored
|
|
@ -43,7 +43,7 @@
|
|||
// Logs are written to standard error instead of to files.
|
||||
// -alsologtostderr=false
|
||||
// Logs are written to standard error as well as to files.
|
||||
// -stderrthreshold=INFO
|
||||
// -stderrthreshold=ERROR
|
||||
// Log events at or above this severity are logged to standard
|
||||
// error as well as to files.
|
||||
// -log_dir=""
|
||||
|
|
@ -78,6 +78,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
stdLog "log"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
|
@ -396,8 +397,8 @@ type flushSyncWriter interface {
|
|||
}
|
||||
|
||||
func init() {
|
||||
// Default stderrThreshold is INFO.
|
||||
logging.stderrThreshold = infoLog
|
||||
// Default stderrThreshold is ERROR.
|
||||
logging.stderrThreshold = errorLog
|
||||
|
||||
logging.setVState(0, nil, false)
|
||||
go logging.flushDaemon()
|
||||
|
|
@ -410,10 +411,14 @@ func InitFlags(flagset *flag.FlagSet) {
|
|||
}
|
||||
flagset.StringVar(&logging.logDir, "log_dir", "", "If non-empty, write log files in this directory")
|
||||
flagset.StringVar(&logging.logFile, "log_file", "", "If non-empty, use this log file")
|
||||
flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", 1800,
|
||||
"Defines the maximum size a log file can grow to. Unit is megabytes. "+
|
||||
"If the value is 0, the maximum file size is unlimited.")
|
||||
flagset.BoolVar(&logging.toStderr, "logtostderr", true, "log to standard error instead of files")
|
||||
flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files")
|
||||
flagset.Var(&logging.verbosity, "v", "number for the log level verbosity")
|
||||
flagset.BoolVar(&logging.skipHeaders, "skip_headers", false, "If true, avoid header prefixes in the log messages")
|
||||
flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", false, "If true, avoid headers when openning log files")
|
||||
flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
|
||||
flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
|
||||
flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")
|
||||
|
|
@ -471,8 +476,15 @@ type loggingT struct {
|
|||
// 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
|
||||
// logFile will be cleaned up. If this value is 0, no size limitation will be applied to logFile.
|
||||
logFileMaxSizeMB uint64
|
||||
|
||||
// If true, do not add the prefix headers, useful when used with SetOutput
|
||||
skipHeaders bool
|
||||
|
||||
// If true, do not add the headers to log files
|
||||
skipLogHeaders bool
|
||||
}
|
||||
|
||||
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
|
||||
|
|
@ -739,9 +751,7 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
|
|||
}
|
||||
data := buf.Bytes()
|
||||
if l.toStderr {
|
||||
if s >= l.stderrThreshold.get() {
|
||||
os.Stderr.Write(data)
|
||||
}
|
||||
os.Stderr.Write(data)
|
||||
} else {
|
||||
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
|
||||
os.Stderr.Write(data)
|
||||
|
|
@ -863,18 +873,33 @@ func (l *loggingT) exit(err error) {
|
|||
type syncBuffer struct {
|
||||
logger *loggingT
|
||||
*bufio.Writer
|
||||
file *os.File
|
||||
sev severity
|
||||
nbytes uint64 // The number of bytes written to this file
|
||||
file *os.File
|
||||
sev severity
|
||||
nbytes uint64 // The number of bytes written to this file
|
||||
maxbytes uint64 // The max number of bytes this syncBuffer.file can hold before cleaning up.
|
||||
}
|
||||
|
||||
func (sb *syncBuffer) Sync() error {
|
||||
return sb.file.Sync()
|
||||
}
|
||||
|
||||
// CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options.
|
||||
func CalculateMaxSize() uint64 {
|
||||
if logging.logFile != "" {
|
||||
if logging.logFileMaxSizeMB == 0 {
|
||||
// If logFileMaxSizeMB is zero, we don't have limitations on the log size.
|
||||
return math.MaxUint64
|
||||
}
|
||||
// Flag logFileMaxSizeMB is in MB for user convenience.
|
||||
return logging.logFileMaxSizeMB * 1024 * 1024
|
||||
}
|
||||
// If "log_file" flag is not specified, the target file (sb.file) will be cleaned up when reaches a fixed size.
|
||||
return MaxSize
|
||||
}
|
||||
|
||||
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
|
||||
if sb.nbytes+uint64(len(p)) >= MaxSize {
|
||||
if err := sb.rotateFile(time.Now()); err != nil {
|
||||
if sb.nbytes+uint64(len(p)) >= sb.maxbytes {
|
||||
if err := sb.rotateFile(time.Now(), false); err != nil {
|
||||
sb.logger.exit(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -887,13 +912,15 @@ func (sb *syncBuffer) Write(p []byte) (n int, err error) {
|
|||
}
|
||||
|
||||
// rotateFile closes the syncBuffer's file and starts a new one.
|
||||
func (sb *syncBuffer) rotateFile(now time.Time) error {
|
||||
// The startup argument indicates whether this is the initial startup of klog.
|
||||
// If startup is true, existing files are opened for appending instead of truncated.
|
||||
func (sb *syncBuffer) rotateFile(now time.Time, startup bool) error {
|
||||
if sb.file != nil {
|
||||
sb.Flush()
|
||||
sb.file.Close()
|
||||
}
|
||||
var err error
|
||||
sb.file, _, err = create(severityName[sb.sev], now)
|
||||
sb.file, _, err = create(severityName[sb.sev], now, startup)
|
||||
sb.nbytes = 0
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -901,6 +928,10 @@ func (sb *syncBuffer) rotateFile(now time.Time) error {
|
|||
|
||||
sb.Writer = bufio.NewWriterSize(sb.file, bufferSize)
|
||||
|
||||
if sb.logger.skipLogHeaders {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Write header.
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05"))
|
||||
|
|
@ -925,10 +956,11 @@ func (l *loggingT) createFiles(sev severity) error {
|
|||
// has already been created, we can stop.
|
||||
for s := sev; s >= infoLog && l.file[s] == nil; s-- {
|
||||
sb := &syncBuffer{
|
||||
logger: l,
|
||||
sev: s,
|
||||
logger: l,
|
||||
sev: s,
|
||||
maxbytes: CalculateMaxSize(),
|
||||
}
|
||||
if err := sb.rotateFile(now); err != nil {
|
||||
if err := sb.rotateFile(now, true); err != nil {
|
||||
return err
|
||||
}
|
||||
l.file[s] = sb
|
||||
|
|
|
|||
19
vendor/k8s.io/klog/klog_file.go
generated
vendored
19
vendor/k8s.io/klog/klog_file.go
generated
vendored
|
|
@ -97,9 +97,11 @@ var onceLogDirs sync.Once
|
|||
// contains tag ("INFO", "FATAL", etc.) and t. If the file is created
|
||||
// successfully, create also attempts to update the symlink for that tag, ignoring
|
||||
// errors.
|
||||
func create(tag string, t time.Time) (f *os.File, filename string, err error) {
|
||||
// The startup argument indicates whether this is the initial startup of klog.
|
||||
// If startup is true, existing files are opened for appending instead of truncated.
|
||||
func create(tag string, t time.Time, startup bool) (f *os.File, filename string, err error) {
|
||||
if logging.logFile != "" {
|
||||
f, err := os.Create(logging.logFile)
|
||||
f, err := openOrCreate(logging.logFile, startup)
|
||||
if err == nil {
|
||||
return f, logging.logFile, nil
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ func create(tag string, t time.Time) (f *os.File, filename string, err error) {
|
|||
var lastErr error
|
||||
for _, dir := range logDirs {
|
||||
fname := filepath.Join(dir, name)
|
||||
f, err := os.Create(fname)
|
||||
f, err := openOrCreate(fname, startup)
|
||||
if err == nil {
|
||||
symlink := filepath.Join(dir, link)
|
||||
os.Remove(symlink) // ignore err
|
||||
|
|
@ -124,3 +126,14 @@ func create(tag string, t time.Time) (f *os.File, filename string, err error) {
|
|||
}
|
||||
return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr)
|
||||
}
|
||||
|
||||
// The startup argument indicates whether this is the initial startup of klog.
|
||||
// If startup is true, existing files are opened for appending instead of truncated.
|
||||
func openOrCreate(name string, startup bool) (*os.File, error) {
|
||||
if startup {
|
||||
f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
return f, err
|
||||
}
|
||||
f, err := os.Create(name)
|
||||
return f, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue