Skip to content

Commit 8c0f205

Browse files
committed
reformat to golang 1.19 standards
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent 6f5eeb9 commit 8c0f205

File tree

10 files changed

+95
-88
lines changed

10 files changed

+95
-88
lines changed

contextual.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ var (
4747
// If set, all log lines will be suppressed from the regular output, and
4848
// redirected to the logr implementation.
4949
// Use as:
50-
// ...
51-
// klog.SetLogger(zapr.NewLogger(zapLog))
50+
//
51+
// ...
52+
// klog.SetLogger(zapr.NewLogger(zapLog))
5253
//
5354
// To remove a backing logr implemention, use ClearLogger. Setting an
5455
// empty logger with SetLogger(logr.Logger{}) does not work.

klog.go

+41-35
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,38 @@
3939
// This package provides several flags that modify this behavior.
4040
// As a result, flag.Parse must be called before any logging is done.
4141
//
42-
// -logtostderr=true
43-
// Logs are written to standard error instead of to files.
44-
// This shortcuts most of the usual output routing:
45-
// -alsologtostderr, -stderrthreshold and -log_dir have no
46-
// effect and output redirection at runtime with SetOutput is
47-
// ignored.
48-
// -alsologtostderr=false
49-
// Logs are written to standard error as well as to files.
50-
// -stderrthreshold=ERROR
51-
// Log events at or above this severity are logged to standard
52-
// error as well as to files.
53-
// -log_dir=""
54-
// Log files will be written to this directory instead of the
55-
// default temporary directory.
42+
// -logtostderr=true
43+
// Logs are written to standard error instead of to files.
44+
// This shortcuts most of the usual output routing:
45+
// -alsologtostderr, -stderrthreshold and -log_dir have no
46+
// effect and output redirection at runtime with SetOutput is
47+
// ignored.
48+
// -alsologtostderr=false
49+
// Logs are written to standard error as well as to files.
50+
// -stderrthreshold=ERROR
51+
// Log events at or above this severity are logged to standard
52+
// error as well as to files.
53+
// -log_dir=""
54+
// Log files will be written to this directory instead of the
55+
// default temporary directory.
5656
//
57-
// Other flags provide aids to debugging.
58-
//
59-
// -log_backtrace_at=""
60-
// When set to a file and line number holding a logging statement,
61-
// such as
62-
// -log_backtrace_at=gopherflakes.go:234
63-
// a stack trace will be written to the Info log whenever execution
64-
// hits that statement. (Unlike with -vmodule, the ".go" must be
65-
// present.)
66-
// -v=0
67-
// Enable V-leveled logging at the specified level.
68-
// -vmodule=""
69-
// The syntax of the argument is a comma-separated list of pattern=N,
70-
// where pattern is a literal file name (minus the ".go" suffix) or
71-
// "glob" pattern and N is a V level. For instance,
72-
// -vmodule=gopher*=3
73-
// sets the V level to 3 in all Go files whose names begin "gopher".
57+
// Other flags provide aids to debugging.
7458
//
59+
// -log_backtrace_at=""
60+
// When set to a file and line number holding a logging statement,
61+
// such as
62+
// -log_backtrace_at=gopherflakes.go:234
63+
// a stack trace will be written to the Info log whenever execution
64+
// hits that statement. (Unlike with -vmodule, the ".go" must be
65+
// present.)
66+
// -v=0
67+
// Enable V-leveled logging at the specified level.
68+
// -vmodule=""
69+
// The syntax of the argument is a comma-separated list of pattern=N,
70+
// where pattern is a literal file name (minus the ".go" suffix) or
71+
// "glob" pattern and N is a V level. For instance,
72+
// -vmodule=gopher*=3
73+
// sets the V level to 3 in all Go files whose names begin "gopher".
7574
package klog
7675

7776
import (
@@ -633,8 +632,11 @@ It returns a buffer containing the formatted header and the user's file and line
633632
The depth specifies how many stack frames above lives the source line to be identified in the log message.
634633
635634
Log lines have this form:
635+
636636
Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
637+
637638
where the fields are defined as follows:
639+
638640
L A single character, representing the log level (eg 'I' for INFO)
639641
mm The month (zero padded; ie May is '05')
640642
dd The day (zero padded)
@@ -1298,9 +1300,13 @@ func newVerbose(level Level, b bool) Verbose {
12981300
// The returned value is a struct of type Verbose, which implements Info, Infoln
12991301
// and Infof. These methods will write to the Info log if called.
13001302
// Thus, one may write either
1303+
//
13011304
// if klog.V(2).Enabled() { klog.Info("log this") }
1305+
//
13021306
// or
1307+
//
13031308
// klog.V(2).Info("log this")
1309+
//
13041310
// The second form is shorter but the first is cheaper if logging is off because it does
13051311
// not evaluate its arguments.
13061312
//
@@ -1582,10 +1588,10 @@ func ErrorSDepth(depth int, err error, msg string, keysAndValues ...interface{})
15821588
//
15831589
// Callers who want more control over handling of fatal events may instead use a
15841590
// combination of different functions:
1585-
// - some info or error logging function, optionally with a stack trace
1586-
// value generated by github.com/go-logr/lib/dbg.Backtrace
1587-
// - Flush to flush pending log data
1588-
// - panic, os.Exit or returning to the caller with an error
1591+
// - some info or error logging function, optionally with a stack trace
1592+
// value generated by github.com/go-logr/lib/dbg.Backtrace
1593+
// - Flush to flush pending log data
1594+
// - panic, os.Exit or returning to the caller with an error
15891595
//
15901596
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
15911597
func Fatal(args ...interface{}) {

ktesting/init/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
// the flag.CommandLine. This is done during initialization, so merely
1919
// importing it is enough.
2020
//
21-
// Experimental
21+
// # Experimental
2222
//
2323
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
2424
// later release.

ktesting/options.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
//
3030
// Must be constructed with NewConfig.
3131
//
32-
// Experimental
32+
// # Experimental
3333
//
3434
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
3535
// later release.
@@ -40,7 +40,7 @@ type Config struct {
4040

4141
// ConfigOption implements functional parameters for NewConfig.
4242
//
43-
// Experimental
43+
// # Experimental
4444
//
4545
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
4646
// later release.
@@ -54,7 +54,7 @@ type configOptions struct {
5454

5555
// VerbosityFlagName overrides the default -testing.v for the verbosity level.
5656
//
57-
// Experimental
57+
// # Experimental
5858
//
5959
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
6060
// later release.
@@ -67,7 +67,7 @@ func VerbosityFlagName(name string) ConfigOption {
6767
// VModulFlagName overrides the default -testing.vmodule for the per-module
6868
// verbosity levels.
6969
//
70-
// Experimental
70+
// # Experimental
7171
//
7272
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
7373
// later release.
@@ -84,7 +84,7 @@ func VModuleFlagName(name string) ConfigOption {
8484
// which is useful when debugging a failed test. `go test` only shows the log
8585
// output for failed tests. To see all output, use `go test -v`.
8686
//
87-
// Experimental
87+
// # Experimental
8888
//
8989
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
9090
// later release.
@@ -97,7 +97,7 @@ func Verbosity(level int) ConfigOption {
9797
// NewConfig returns a configuration with recommended defaults and optional
9898
// modifications. Command line flags are not bound to any FlagSet yet.
9999
//
100-
// Experimental
100+
// # Experimental
101101
//
102102
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
103103
// later release.
@@ -120,7 +120,7 @@ func NewConfig(opts ...ConfigOption) *Config {
120120

121121
// AddFlags registers the command line flags that control the configuration.
122122
//
123-
// Experimental
123+
// # Experimental
124124
//
125125
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
126126
// later release.

ktesting/setup.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
// DefaultConfig is the global default logging configuration for a unit
2626
// test. It is used by NewTestContext and k8s.io/klogr/testing/init.
2727
//
28-
// Experimental
28+
// # Experimental
2929
//
3030
// Notice: This variable is EXPERIMENTAL and may be changed or removed in a
3131
// later release.
@@ -36,7 +36,7 @@ var DefaultConfig = NewConfig()
3636
// will receive all log output. Importing k8s.io/klogr/testing/init will add
3737
// command line flags that modify the configuration of that log output.
3838
//
39-
// Experimental
39+
// # Experimental
4040
//
4141
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
4242
// later release.

ktesting/testinglogger.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ limitations under the License.
2525
// access to that data, cast the LogSink into the Underlier type and retrieve
2626
// it:
2727
//
28-
// logger := ktesting.NewLogger(...)
29-
// if testingLogger, ok := logger.GetSink().(ktesting.Underlier); ok {
30-
// t := testingLogger.GetUnderlying()
31-
// buffer := testingLogger.GetBuffer()
32-
// text := buffer.String()
33-
// log := buffer.Data()
28+
// logger := ktesting.NewLogger(...)
29+
// if testingLogger, ok := logger.GetSink().(ktesting.Underlier); ok {
30+
// t := testingLogger.GetUnderlying()
31+
// buffer := testingLogger.GetBuffer()
32+
// text := buffer.String()
33+
// log := buffer.Data()
3434
//
3535
// Serialization of the structured log parameters is done in the same way
3636
// as for klog.InfoS.
3737
//
38-
// Experimental
38+
// # Experimental
3939
//
4040
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
4141
// later release.
@@ -57,7 +57,7 @@ import (
5757

5858
// TL is the relevant subset of testing.TB.
5959
//
60-
// Experimental
60+
// # Experimental
6161
//
6262
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
6363
// later release.
@@ -69,7 +69,7 @@ type TL interface {
6969
// NopTL implements TL with empty stubs. It can be used when only capturing
7070
// output in memory is relevant.
7171
//
72-
// Experimental
72+
// # Experimental
7373
//
7474
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
7575
// later release.
@@ -88,7 +88,7 @@ var _ TL = NopTL{}
8888
// that output will be printed via the global klog logger with
8989
// `<test name> leaked goroutine` as prefix.
9090
//
91-
// Experimental
91+
// # Experimental
9292
//
9393
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
9494
// later release.
@@ -117,7 +117,7 @@ func NewLogger(t TL, c *Config) logr.Logger {
117117
// Buffer stores log entries as formatted text and structured data.
118118
// It is safe to use this concurrently.
119119
//
120-
// Experimental
120+
// # Experimental
121121
//
122122
// Notice: This interface is EXPERIMENTAL and may be changed or removed in a
123123
// later release.
@@ -132,7 +132,7 @@ type Buffer interface {
132132

133133
// Log contains log entries in the order in which they were generated.
134134
//
135-
// Experimental
135+
// # Experimental
136136
//
137137
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
138138
// later release.
@@ -141,7 +141,7 @@ type Log []LogEntry
141141
// DeepCopy returns a copy of the log. The error instance and key/value
142142
// pairs remain shared.
143143
//
144-
// Experimental
144+
// # Experimental
145145
//
146146
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
147147
// later release.
@@ -153,7 +153,7 @@ func (l Log) DeepCopy() Log {
153153

154154
// LogEntry represents all information captured for a log entry.
155155
//
156-
// Experimental
156+
// # Experimental
157157
//
158158
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
159159
// later release.
@@ -190,7 +190,7 @@ type LogEntry struct {
190190
// LogType determines whether a log entry was created with an Error or Info
191191
// call.
192192
//
193-
// Experimental
193+
// # Experimental
194194
//
195195
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
196196
// later release.
@@ -217,7 +217,7 @@ const (
217217
// Underlier is implemented by the LogSink of this logger. It provides access
218218
// to additional APIs that are normally hidden behind the Logger API.
219219
//
220-
// Experimental
220+
// # Experimental
221221
//
222222
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
223223
// later release.

test/output.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
// Package test contains a reusable unit test for logging output and behavior.
1818
//
19-
// Experimental
19+
// # Experimental
2020
//
2121
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
2222
// later release.
@@ -44,7 +44,7 @@ import (
4444
// InitKlog must be called once in an init function of a test package to
4545
// configure klog for testing with Output.
4646
//
47-
// Experimental
47+
// # Experimental
4848
//
4949
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
5050
// later release.
@@ -61,7 +61,7 @@ func InitKlog() {
6161

6262
// OutputConfig contains optional settings for Output.
6363
//
64-
// Experimental
64+
// # Experimental
6565
//
6666
// Notice: This type is EXPERIMENTAL and may be changed or removed in a
6767
// later release.
@@ -103,7 +103,7 @@ type OutputConfig struct {
103103
// Loggers will be tested with direct calls to Info or
104104
// as backend for klog.
105105
//
106-
// Experimental
106+
// # Experimental
107107
//
108108
// Notice: This function is EXPERIMENTAL and may be changed or removed in a
109109
// later release. The test cases and thus the expected output also may

test/zapr.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package test
1919
// ZaprOutputMappingDirect provides a mapping from klog output to the
2020
// corresponding zapr output when zapr is called directly.
2121
//
22-
// Experimental
22+
// # Experimental
2323
//
2424
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
2525
// later release.
@@ -241,18 +241,18 @@ I output.go:<LINE>] "odd WithValues" keyWithoutValue="(MISSING)"
241241
// klog.
242242
//
243243
// This is different from ZaprOutputMappingDirect because:
244-
// - WithName gets added to the message by Output.
245-
// - zap uses . as separator instead of / between WithName values,
246-
// here we get slashes because Output concatenates these values.
247-
// - WithValues are added to the normal key/value parameters by
248-
// Output, which puts them after "v".
249-
// - Output does that without emitting the warning that we get
250-
// from zapr.
251-
// - zap drops keys with missing values, here we get "(MISSING)".
252-
// - zap does not de-duplicate key/value pairs, here klog does that
253-
// for it.
244+
// - WithName gets added to the message by Output.
245+
// - zap uses . as separator instead of / between WithName values,
246+
// here we get slashes because Output concatenates these values.
247+
// - WithValues are added to the normal key/value parameters by
248+
// Output, which puts them after "v".
249+
// - Output does that without emitting the warning that we get
250+
// from zapr.
251+
// - zap drops keys with missing values, here we get "(MISSING)".
252+
// - zap does not de-duplicate key/value pairs, here klog does that
253+
// for it.
254254
//
255-
// Experimental
255+
// # Experimental
256256
//
257257
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
258258
// later release.

0 commit comments

Comments
 (0)