Skip to content

Commit fb5868b

Browse files
authored
Merge pull request #9106 from thaJeztah/1.7_backport_swap_log_pkg_alias
[release/1.7 backport] alias log package to github.com/containerd/log v0.1.0
2 parents 0736d5b + 09633b5 commit fb5868b

27 files changed

Lines changed: 1730 additions & 812 deletions

.golangci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ issues:
3333
# conversion is necessary on Linux, unnecessary on macOS
3434
text: "unnecessary conversion"
3535

36+
# FIXME temporarily suppress deprecation warnings for the logs package. See https://github.com/containerd/containerd/pull/9086
37+
- text: "SA1019: log\\.(G|L|Fields|Entry|RFC3339NanoFixed|Level|TraceLevel|DebugLevel|InfoLevel|WarnLevel|ErrorLevel|FatalLevel|PanicLevel|SetLevel|GetLevel|OutputFormat|TextFormat|JSONFormat|SetFormat|WithLogger|GetLogger)"
38+
linters:
39+
- staticcheck
40+
- text: "SA1019: logtest\\.WithT"
41+
linters:
42+
- staticcheck
43+
44+
3645
linters-settings:
3746
gosec:
3847
# The following issues surfaced when `gosec` linter

go.mod

Lines changed: 3 additions & 2 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.0.0
1919
github.com/containerd/imgcrypt v1.1.7
20+
github.com/containerd/log v0.1.0
2021
github.com/containerd/nri v0.4.0
2122
github.com/containerd/ttrpc v1.2.2
2223
github.com/containerd/typeurl/v2 v2.1.1
@@ -52,8 +53,8 @@ require (
5253
github.com/opencontainers/selinux v1.11.0
5354
github.com/pelletier/go-toml v1.9.5
5455
github.com/prometheus/client_golang v1.14.0
55-
github.com/sirupsen/logrus v1.9.0
56-
github.com/stretchr/testify v1.8.2
56+
github.com/sirupsen/logrus v1.9.3
57+
github.com/stretchr/testify v1.8.4
5758
github.com/tchap/go-patricia/v2 v2.3.1
5859
github.com/urfave/cli v1.22.12
5960
github.com/vishvananda/netlink v1.2.1-beta.2

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ github.com/containerd/imgcrypt v1.1.3/go.mod h1:/TPA1GIDXMzbj01yd8pIbQiLdQxed5ue
265265
github.com/containerd/imgcrypt v1.1.4/go.mod h1:LorQnPtzL/T0IyCeftcsMEO7AqxUDbdO8j/tSUpgxvo=
266266
github.com/containerd/imgcrypt v1.1.7 h1:WSf9o9EQ0KGHiUx2ESFZ+PKf4nxK9BcvV/nJDX8RkB4=
267267
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
268+
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
269+
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
268270
github.com/containerd/nri v0.0.0-20201007170849-eb1350a75164/go.mod h1:+2wGSDGFYfE5+So4M5syatU0N0f0LbWpuqyMi4/BE8c=
269271
github.com/containerd/nri v0.0.0-20210316161719-dbaa18c31c14/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
270272
github.com/containerd/nri v0.1.0/go.mod h1:lmxnXF6oMkbqs39FiCt1s0R2HSMhcLel9vNL3m4AaeY=
@@ -895,8 +897,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
895897
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
896898
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
897899
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
898-
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
899-
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
900+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
901+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
900902
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
901903
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
902904
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
@@ -939,8 +941,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
939941
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
940942
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
941943
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
942-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
943-
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
944+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
945+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
944946
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
945947
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
946948
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=

integration/client/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/opencontainers/go-digest v1.0.0
1717
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
1818
github.com/opencontainers/runtime-spec v1.1.0-rc.1
19-
github.com/stretchr/testify v1.8.2
19+
github.com/stretchr/testify v1.8.4
2020
go.opentelemetry.io/otel v1.14.0
2121
go.opentelemetry.io/otel/sdk v1.14.0
2222
golang.org/x/sys v0.7.0
@@ -28,6 +28,7 @@ require (
2828
github.com/containerd/cgroups v1.1.0 // indirect
2929
github.com/containerd/console v1.0.3 // indirect
3030
github.com/containerd/fifo v1.1.0 // indirect
31+
github.com/containerd/log v0.1.0 // indirect
3132
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
3233
github.com/davecgh/go-spew v1.1.1 // indirect
3334
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
@@ -51,7 +52,7 @@ require (
5152
github.com/pelletier/go-toml v1.9.5 // indirect
5253
github.com/pkg/errors v0.9.1 // indirect
5354
github.com/pmezard/go-difflib v1.0.0 // indirect
54-
github.com/sirupsen/logrus v1.9.0 // indirect
55+
github.com/sirupsen/logrus v1.9.3 // indirect
5556
go.opencensus.io v0.24.0 // indirect
5657
go.opentelemetry.io/otel/trace v1.14.0 // indirect
5758
golang.org/x/mod v0.9.0 // indirect

integration/client/go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0/go.mod h1:cNU0Z
669669
github.com/containerd/go-runc v1.0.0 h1:oU+lLv1ULm5taqgV/CJivypVODI4SUz1znWjv3nNYS0=
670670
github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok=
671671
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
672+
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
673+
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
672674
github.com/containerd/nri v0.4.0/go.mod h1:Zw9q2lP16sdg0zYybemZ9yTDy8g7fPCIB3KXOGlggXI=
673675
github.com/containerd/stargz-snapshotter/estargz v0.4.1/go.mod h1:x7Q9dg9QYb4+ELgxmo4gBUeJB0tl5dqH1Sdz0nJU1QM=
674676
github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o=
@@ -1290,8 +1292,9 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
12901292
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
12911293
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
12921294
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
1293-
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
12941295
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
1296+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
1297+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
12951298
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
12961299
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
12971300
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
@@ -1337,8 +1340,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
13371340
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
13381341
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
13391342
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
1340-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
13411343
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
1344+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1345+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
13421346
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
13431347
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
13441348
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=

log/context_deprecated.go

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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+
//
27+
// Deprecated: use [log.G].
28+
var G = log.G
29+
30+
// L is an alias for the standard logger.
31+
//
32+
// Deprecated: use [log.L].
33+
var L = log.L
34+
35+
// Fields type to pass to "WithFields".
36+
//
37+
// Deprecated: use [log.Fields].
38+
type Fields = log.Fields
39+
40+
// Entry is a logging entry.
41+
//
42+
// Deprecated: use [log.Entry].
43+
type Entry = log.Entry
44+
45+
// RFC3339NanoFixed is [time.RFC3339Nano] with nanoseconds padded using
46+
// zeros to ensure the formatted time is always the same number of
47+
// characters.
48+
//
49+
// Deprecated: use [log.RFC3339NanoFixed].
50+
const RFC3339NanoFixed = log.RFC3339NanoFixed
51+
52+
// Level is a logging level.
53+
//
54+
// Deprecated: use [log.Level].
55+
type Level = log.Level
56+
57+
// Supported log levels.
58+
const (
59+
// TraceLevel level.
60+
//
61+
// Deprecated: use [log.TraceLevel].
62+
TraceLevel Level = log.TraceLevel
63+
64+
// DebugLevel level.
65+
//
66+
// Deprecated: use [log.DebugLevel].
67+
DebugLevel Level = log.DebugLevel
68+
69+
// InfoLevel level.
70+
//
71+
// Deprecated: use [log.InfoLevel].
72+
InfoLevel Level = log.InfoLevel
73+
74+
// WarnLevel level.
75+
//
76+
// Deprecated: use [log.WarnLevel].
77+
WarnLevel Level = log.WarnLevel
78+
79+
// ErrorLevel level
80+
//
81+
// Deprecated: use [log.ErrorLevel].
82+
ErrorLevel Level = log.ErrorLevel
83+
84+
// FatalLevel level.
85+
//
86+
// Deprecated: use [log.FatalLevel].
87+
FatalLevel Level = log.FatalLevel
88+
89+
// PanicLevel level.
90+
//
91+
// Deprecated: use [log.PanicLevel].
92+
PanicLevel Level = log.PanicLevel
93+
)
94+
95+
// SetLevel sets log level globally. It returns an error if the given
96+
// level is not supported.
97+
//
98+
// Deprecated: use [log.SetLevel].
99+
func SetLevel(level string) error {
100+
return log.SetLevel(level)
101+
}
102+
103+
// GetLevel returns the current log level.
104+
//
105+
// Deprecated: use [log.GetLevel].
106+
func GetLevel() log.Level {
107+
return log.GetLevel()
108+
}
109+
110+
// OutputFormat specifies a log output format.
111+
//
112+
// Deprecated: use [log.OutputFormat].
113+
type OutputFormat = log.OutputFormat
114+
115+
// Supported log output formats.
116+
const (
117+
// TextFormat represents the text logging format.
118+
//
119+
// Deprecated: use [log.TextFormat].
120+
TextFormat log.OutputFormat = "text"
121+
122+
// JSONFormat represents the JSON logging format.
123+
//
124+
// Deprecated: use [log.JSONFormat].
125+
JSONFormat log.OutputFormat = "json"
126+
)
127+
128+
// SetFormat sets the log output format.
129+
//
130+
// Deprecated: use [log.SetFormat].
131+
func SetFormat(format OutputFormat) error {
132+
return log.SetFormat(format)
133+
}
134+
135+
// WithLogger returns a new context with the provided logger. Use in
136+
// combination with logger.WithField(s) for great effect.
137+
//
138+
// Deprecated: use [log.WithLogger].
139+
func WithLogger(ctx context.Context, logger *log.Entry) context.Context {
140+
return log.WithLogger(ctx, logger)
141+
}
142+
143+
// GetLogger retrieves the current logger from the context. If no logger is
144+
// available, the default logger is returned.
145+
//
146+
// Deprecated: use [log.GetLogger].
147+
func GetLogger(ctx context.Context) *log.Entry {
148+
return log.GetLogger(ctx)
149+
}

log/context_test.go

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

log/logtest/context_deprecated.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
//
30+
// Deprecated: use [logtest.WithT].
31+
func WithT(ctx context.Context, t testing.TB) context.Context {
32+
return logtest.WithT(ctx, t)
33+
}

0 commit comments

Comments
 (0)