1klog 2==== 3 4klog is a permanent fork of https://github.com/golang/glog. 5 6## Why was klog created? 7 8The decision to create klog was one that wasn't made lightly, but it was necessary due to some 9drawbacks 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: 10 11> The code in this repo [...] is not itself under development 12 13This makes us unable to solve many use cases without a fork. The factors that contributed to needing feature development are listed below: 14 15 * `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. 16 * `glog` doesn't provide an easy way to test logs, which detracts from the stability of software using it 17 * A long term goal is to implement a logging interface that allows us to add context, change output format, etc. 18 19Historical context is available here: 20 21 * https://github.com/kubernetes/kubernetes/issues/61006 22 * https://github.com/kubernetes/kubernetes/issues/70264 23 * https://groups.google.com/forum/#!msg/kubernetes-sig-architecture/wCWiWf3Juzs/hXRVBH90CgAJ 24 * https://groups.google.com/forum/#!msg/kubernetes-dev/7vnijOMhLS0/1oRiNtigBgAJ 25 26---- 27 28How to use klog 29=============== 30- Replace imports for `github.com/golang/glog` with `k8s.io/klog` 31- Use `klog.InitFlags(nil)` explicitly for initializing global flags as we no longer use `init()` method to register the flags 32- You can now use `log-file` instead of `log-dir` for logging to a single file (See `examples/log_file/usage_log_file.go`) 33- 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`) 34- For more logging conventions (See [Logging Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md)) 35 36### Coexisting with glog 37This 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`. 38 39## Community, discussion, contribution, and support 40 41Learn how to engage with the Kubernetes community on the [community page](http://kubernetes.io/community/). 42 43You can reach the maintainers of this project at: 44 45- [Slack](https://kubernetes.slack.com/messages/sig-architecture) 46- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture) 47 48### Code of conduct 49 50Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md). 51 52---- 53 54glog 55==== 56 57Leveled execution logs for Go. 58 59This is an efficient pure Go implementation of leveled logs in the 60manner of the open source C++ package 61 https://github.com/google/glog 62 63By binding methods to booleans it is possible to use the log package 64without paying the expense of evaluating the arguments to the log. 65Through the -vmodule flag, the package also provides fine-grained 66control over logging at the file level. 67 68The comment from glog.go introduces the ideas: 69 70 Package glog implements logging analogous to the Google-internal 71 C++ INFO/ERROR/V setup. It provides functions Info, Warning, 72 Error, Fatal, plus formatting variants such as Infof. It 73 also provides V-style logging controlled by the -v and 74 -vmodule=file=2 flags. 75 76 Basic examples: 77 78 glog.Info("Prepare to repel boarders") 79 80 glog.Fatalf("Initialization failed: %s", err) 81 82 See the documentation for the V function for an explanation 83 of these examples: 84 85 if glog.V(2) { 86 glog.Info("Starting transaction...") 87 } 88 89 glog.V(2).Infoln("Processed", nItems, "elements") 90 91 92The repository contains an open source version of the log package 93used inside Google. The master copy of the source lives inside 94Google, not here. The code in this repo is for export only and is not itself 95under development. Feature requests will be ignored. 96 97Send bug reports to golang-nuts@googlegroups.com. 98