mirror of https://github.com/k3s-io/k3s
Update klog dependency
parent
098075c458
commit
4a4c1a6239
|
@ -4227,7 +4227,8 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Comment": "v0.2.0-14-g8e90cee79f8237",
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/cmd/openapi-gen",
|
||||
|
|
|
@ -240,7 +240,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
|
||||
|
|
|
@ -2256,7 +2256,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/builder",
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -1972,7 +1972,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/builder",
|
||||
|
|
|
@ -652,7 +652,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
||||
|
|
|
@ -616,7 +616,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -992,7 +992,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/utils/pointer",
|
||||
|
|
|
@ -536,7 +536,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1812,7 +1812,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/aggregator",
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/utils/pointer",
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/utils/pointer",
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/utils/pointer",
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -512,7 +512,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -536,7 +536,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -1768,7 +1768,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/builder",
|
||||
|
|
|
@ -724,7 +724,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/common",
|
||||
|
|
|
@ -1176,7 +1176,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
"Rev": "8e90cee79f823779174776412c13478955131846"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
language: go
|
||||
go_import_path: k8s.io/klog
|
||||
dist: xenial
|
||||
go:
|
||||
- 1.9.x
|
||||
|
|
|
@ -8,10 +8,6 @@ _As contributors and maintainers of this project, and in the interest of fosteri
|
|||
|
||||
We have full documentation on how to get started contributing here:
|
||||
|
||||
<!---
|
||||
If your repo has certain guidelines for contribution, put them here ahead of the general k8s resources
|
||||
-->
|
||||
|
||||
- [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.md) - Common resources for existing developers
|
||||
|
@ -20,12 +16,7 @@ If your repo has certain guidelines for contribution, put them here ahead of the
|
|||
|
||||
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!
|
||||
|
||||
<!---
|
||||
Custom Information - if you're copying this template for the first time you can add custom content here, for example:
|
||||
|
||||
## Contact Information
|
||||
|
||||
- [Slack channel](https://kubernetes.slack.com/messages/kubernetes-users) - Replace `kubernetes-users` with your slack channel string, this will send users directly to your channel.
|
||||
- [Mailing list](URL)
|
||||
|
||||
-->
|
||||
- [Slack](https://kubernetes.slack.com/messages/sig-architecture)
|
||||
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture)
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
|
||||
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
reviewers:
|
||||
- jayunit100
|
||||
- hoegaarden
|
||||
- andyxning
|
||||
- neolit123
|
||||
- pohly
|
||||
- yagonobre
|
||||
- vincepri
|
||||
- detiber
|
||||
approvers:
|
||||
- dims
|
||||
- thockin
|
||||
|
|
|
@ -5,6 +5,32 @@ klog is a permanant fork of https://github.com/golang/glog. original README from
|
|||
|
||||
----
|
||||
|
||||
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`)
|
||||
- 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))
|
||||
|
||||
### 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`.
|
||||
|
||||
## Community, discussion, contribution, and support
|
||||
|
||||
Learn how to engage with the Kubernetes community on the [community page](http://kubernetes.io/community/).
|
||||
|
||||
You can reach the maintainers of this project at:
|
||||
|
||||
- [Slack](https://kubernetes.slack.com/messages/sig-architecture)
|
||||
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture)
|
||||
|
||||
### Code of conduct
|
||||
|
||||
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md).
|
||||
|
||||
----
|
||||
|
||||
glog
|
||||
====
|
||||
|
||||
|
@ -26,20 +52,20 @@ The comment from glog.go introduces the ideas:
|
|||
Error, Fatal, plus formatting variants such as Infof. It
|
||||
also provides V-style logging controlled by the -v and
|
||||
-vmodule=file=2 flags.
|
||||
|
||||
|
||||
Basic examples:
|
||||
|
||||
|
||||
glog.Info("Prepare to repel boarders")
|
||||
|
||||
|
||||
glog.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...")
|
||||
}
|
||||
|
||||
|
||||
glog.V(2).Infoln("Processed", nItems, "elements")
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Kubernetes Community Code of Conduct
|
||||
|
||||
Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md)
|
|
@ -410,9 +410,9 @@ 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.BoolVar(&logging.toStderr, "logtostderr", false, "log to standard error instead of files")
|
||||
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", "log level for V logs")
|
||||
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.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")
|
||||
|
@ -872,7 +872,7 @@ func (sb *syncBuffer) Sync() error {
|
|||
|
||||
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 err := sb.rotateFile(time.Now(), false); err != nil {
|
||||
sb.logger.exit(err)
|
||||
}
|
||||
}
|
||||
|
@ -885,13 +885,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 apending 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
|
||||
|
@ -926,7 +928,7 @@ func (l *loggingT) createFiles(sev severity) error {
|
|||
logger: l,
|
||||
sev: s,
|
||||
}
|
||||
if err := sb.rotateFile(now); err != nil {
|
||||
if err := sb.rotateFile(now, true); err != nil {
|
||||
return err
|
||||
}
|
||||
l.file[s] = sb
|
||||
|
@ -934,7 +936,7 @@ func (l *loggingT) createFiles(sev severity) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
const flushInterval = 30 * time.Second
|
||||
const flushInterval = 5 * time.Second
|
||||
|
||||
// flushDaemon periodically flushes the log file buffers.
|
||||
func (l *loggingT) flushDaemon() {
|
||||
|
|
|
@ -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 apending 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…
Reference in New Issue