Skip to content

Commit d69ae81

Browse files
committed
alias log package to github.com/containerd/log v0.1.0
This "soft" deprecates the package, but keeps the local uses of the package, which can make backporting this to release-branches easier (we can still move all uses in those branches as well though). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 0066676 commit d69ae81

14 files changed

Lines changed: 387 additions & 64 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/containerd/go-cni v1.1.9
1818
github.com/containerd/go-runc v1.1.0
1919
github.com/containerd/imgcrypt v1.1.7
20+
github.com/containerd/log v0.1.0
2021
github.com/containerd/nri v0.5.0
2122
github.com/containerd/ttrpc v1.2.2
2223
github.com/containerd/typeurl/v2 v2.1.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ github.com/containerd/imgcrypt v1.1.3/go.mod h1:/TPA1GIDXMzbj01yd8pIbQiLdQxed5ue
267267
github.com/containerd/imgcrypt v1.1.4/go.mod h1:LorQnPtzL/T0IyCeftcsMEO7AqxUDbdO8j/tSUpgxvo=
268268
github.com/containerd/imgcrypt v1.1.7 h1:WSf9o9EQ0KGHiUx2ESFZ+PKf4nxK9BcvV/nJDX8RkB4=
269269
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
270+
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
271+
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
270272
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c=
271273
github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
272274
github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=

integration/client/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ require (
2929
github.com/container-orchestrated-devices/container-device-interface v0.6.1 // indirect
3030
github.com/containerd/console v1.0.3 // indirect
3131
github.com/containerd/fifo v1.1.0 // indirect
32+
github.com/containerd/log v0.1.0 // indirect
3233
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
3334
github.com/davecgh/go-spew v1.1.1 // indirect
3435
github.com/distribution/reference v0.5.0 // indirect

integration/client/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDX
896896
github.com/containerd/go-runc v1.1.0 h1:OX4f+/i2y5sUT7LhmcJH7GYrjjhHa1QI4e8yO0gGleA=
897897
github.com/containerd/go-runc v1.1.0/go.mod h1:xJv2hFF7GvHtTJd9JqTS2UVxMkULUYw4JN5XAUZqH5U=
898898
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
899+
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
900+
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
899901
github.com/containerd/nri v0.5.0/go.mod h1:qIu2NlP3r/qK4YGnNuQf0De4VPqQWP2i2CVBfAZbGzg=
900902
github.com/containerd/protobuild v0.3.0/go.mod h1:5mNMFKKAwCIAkFBPiOdtRx2KiQlyEJeMXnL5R1DsWu8=
901903
github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM=

log/context_deprecated.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package log
18+
19+
import (
20+
"context"
21+
22+
"github.com/containerd/log"
23+
)
24+
25+
// G is a shorthand for [GetLogger].
26+
var G = log.G
27+
28+
// L is an alias for the standard logger.
29+
var L = log.L
30+
31+
// Fields type to pass to "WithFields".
32+
type Fields = log.Fields
33+
34+
// Entry is a logging entry.
35+
type Entry = log.Entry
36+
37+
// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using
38+
// zeros to ensure the formatted time is always the same number of
39+
// characters.
40+
const RFC3339NanoFixed = log.RFC3339NanoFixed
41+
42+
// Level is a logging level.
43+
type Level = log.Level
44+
45+
// Supported log levels.
46+
const (
47+
// TraceLevel level.
48+
TraceLevel Level = log.TraceLevel
49+
50+
// DebugLevel level.
51+
DebugLevel Level = log.DebugLevel
52+
53+
// InfoLevel level.
54+
InfoLevel Level = log.InfoLevel
55+
56+
// WarnLevel level.
57+
WarnLevel Level = log.WarnLevel
58+
59+
// ErrorLevel level
60+
ErrorLevel Level = log.ErrorLevel
61+
62+
// FatalLevel level.
63+
FatalLevel Level = log.FatalLevel
64+
65+
// PanicLevel level.
66+
PanicLevel Level = log.PanicLevel
67+
)
68+
69+
// SetLevel sets log level globally. It returns an error if the given
70+
// level is not supported.
71+
func SetLevel(level string) error {
72+
return log.SetLevel(level)
73+
}
74+
75+
// GetLevel returns the current log level.
76+
func GetLevel() log.Level {
77+
return log.GetLevel()
78+
}
79+
80+
// OutputFormat specifies a log output format.
81+
type OutputFormat = log.OutputFormat
82+
83+
// Supported log output formats.
84+
const (
85+
// TextFormat represents the text logging format.
86+
TextFormat log.OutputFormat = "text"
87+
88+
// JSONFormat represents the JSON logging format.
89+
JSONFormat log.OutputFormat = "json"
90+
)
91+
92+
// SetFormat sets the log output format.
93+
func SetFormat(format OutputFormat) error {
94+
return log.SetFormat(format)
95+
}
96+
97+
// WithLogger returns a new context with the provided logger. Use in
98+
// combination with logger.WithField(s) for great effect.
99+
func WithLogger(ctx context.Context, logger *log.Entry) context.Context {
100+
return log.WithLogger(ctx, logger)
101+
}
102+
103+
// GetLogger retrieves the current logger from the context. If no logger is
104+
// available, the default logger is returned.
105+
func GetLogger(ctx context.Context) *log.Entry {
106+
return log.GetLogger(ctx)
107+
}

log/context_test.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

log/logtest/context_deprecated.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package logtest
18+
19+
import (
20+
"context"
21+
"testing"
22+
23+
"github.com/containerd/log/logtest"
24+
)
25+
26+
// WithT adds a logging hook for the given test
27+
// Changes debug level to debug, clears output, and
28+
// outputs all log messages as test logs.
29+
func WithT(ctx context.Context, t testing.TB) context.Context {
30+
return logtest.WithT(ctx, t)
31+
}

vendor/github.com/containerd/log/.golangci.yml

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)