Skip to content

Commit 8dd3f2e

Browse files
authored
Merge pull request #395 from pohly/readme-update
docs: clarify relationship between different features
2 parents 761b630 + d3dd725 commit 8dd3f2e

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

klog.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,26 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
// Package klog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
18-
// It provides functions Info, Warning, Error, Fatal, plus formatting variants such as
19-
// Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags.
17+
// Package klog contains the following functionality:
18+
//
19+
// - output routing as defined via command line flags ([InitFlags])
20+
// - log formatting as text, either with a single, unstructured string ([Info], [Infof], etc.)
21+
// or as a structured log entry with message and key/value pairs ([InfoS], etc.)
22+
// - management of a go-logr [Logger] ([SetLogger], [Background], [TODO])
23+
// - helper functions for logging values ([Format]) and managing the state of klog ([CaptureState], [State.Restore])
24+
// - wrappers for [logr] APIs for contextual logging where the wrappers can
25+
// be turned into no-ops ([EnableContextualLogging], [NewContext], [FromContext],
26+
// [LoggerWithValues], [LoggerWithName]); if the ability to turn off
27+
// contextual logging is not needed, then go-logr can also be used directly
28+
// - type aliases for go-logr types to simplify imports in code which uses both (e.g. [Logger])
29+
// - [k8s.io/klog/v2/textlogger]: a logger which uses the same formatting as klog log with
30+
// simpler output routing; beware that it comes with its own command line flags
31+
// and does not use the ones from klog
32+
// - [k8s.io/klog/v2/ktesting]: per-test output in Go unit tests
33+
// - [k8s.io/klog/v2/klogr]: a deprecated, standalone [logr.Logger] on top of the main klog package;
34+
// use [Background] instead if klog output routing is needed, [k8s.io/klog/v2/textlogger] if not
35+
// - [k8s.io/klog/v2/examples]: demos of this functionality
36+
// - [k8s.io/klog/v2/test]: reusable tests for [logr.Logger] implementations
2037
//
2138
// Basic examples:
2239
//

textlogger/textlogger.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
// Package textlogger contains an implementation of the logr interface
19-
// which is producing the exact same output as klog.
18+
// Package textlogger contains an implementation of the logr interface which is
19+
// producing the exact same output as klog. It does not route output through
20+
// klog (i.e. ignores [k8s.io/klog/v2.InitFlags]). Instead, all settings must be
21+
// configured through its own [NewConfig] and [Config.AddFlags].
2022
package textlogger
2123

2224
import (

0 commit comments

Comments
 (0)