log/slog: change XXXCtx functions to XXXContext

Fixes #61200.

Change-Id: I3071dbf673bcd2d24e62644b40d481c953703978
Reviewed-on: https://go-review.googlesource.com/c/go/+/508195
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Jonathan Amsterdam 2023-07-06 13:06:44 -04:00
parent 4c58d6bf52
commit 3f8b04bfb5
4 changed files with 34 additions and 34 deletions

View File

@ -219,18 +219,18 @@ pkg log/slog, func Any(string, interface{}) Attr #56345
pkg log/slog, func AnyValue(interface{}) Value #56345 pkg log/slog, func AnyValue(interface{}) Value #56345
pkg log/slog, func Bool(string, bool) Attr #56345 pkg log/slog, func Bool(string, bool) Attr #56345
pkg log/slog, func BoolValue(bool) Value #56345 pkg log/slog, func BoolValue(bool) Value #56345
pkg log/slog, func DebugCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, func DebugContext(context.Context, string, ...interface{}) #61200
pkg log/slog, func Debug(string, ...interface{}) #56345 pkg log/slog, func Debug(string, ...interface{}) #56345
pkg log/slog, func Default() *Logger #56345 pkg log/slog, func Default() *Logger #56345
pkg log/slog, func Duration(string, time.Duration) Attr #56345 pkg log/slog, func Duration(string, time.Duration) Attr #56345
pkg log/slog, func DurationValue(time.Duration) Value #56345 pkg log/slog, func DurationValue(time.Duration) Value #56345
pkg log/slog, func ErrorCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, func ErrorContext(context.Context, string, ...interface{}) #61200
pkg log/slog, func Error(string, ...interface{}) #56345 pkg log/slog, func Error(string, ...interface{}) #56345
pkg log/slog, func Float64(string, float64) Attr #56345 pkg log/slog, func Float64(string, float64) Attr #56345
pkg log/slog, func Float64Value(float64) Value #56345 pkg log/slog, func Float64Value(float64) Value #56345
pkg log/slog, func Group(string, ...interface{}) Attr #59204 pkg log/slog, func Group(string, ...interface{}) Attr #59204
pkg log/slog, func GroupValue(...Attr) Value #56345 pkg log/slog, func GroupValue(...Attr) Value #56345
pkg log/slog, func InfoCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, func InfoContext(context.Context, string, ...interface{}) #61200
pkg log/slog, func Info(string, ...interface{}) #56345 pkg log/slog, func Info(string, ...interface{}) #56345
pkg log/slog, func Int64(string, int64) Attr #56345 pkg log/slog, func Int64(string, int64) Attr #56345
pkg log/slog, func Int64Value(int64) Value #56345 pkg log/slog, func Int64Value(int64) Value #56345
@ -250,7 +250,7 @@ pkg log/slog, func Time(string, time.Time) Attr #56345
pkg log/slog, func TimeValue(time.Time) Value #56345 pkg log/slog, func TimeValue(time.Time) Value #56345
pkg log/slog, func Uint64(string, uint64) Attr #56345 pkg log/slog, func Uint64(string, uint64) Attr #56345
pkg log/slog, func Uint64Value(uint64) Value #56345 pkg log/slog, func Uint64Value(uint64) Value #56345
pkg log/slog, func WarnCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, func WarnContext(context.Context, string, ...interface{}) #61200
pkg log/slog, func Warn(string, ...interface{}) #56345 pkg log/slog, func Warn(string, ...interface{}) #56345
pkg log/slog, func With(...interface{}) *Logger #56345 pkg log/slog, func With(...interface{}) *Logger #56345
pkg log/slog, method (Attr) Equal(Attr) bool #56345 pkg log/slog, method (Attr) Equal(Attr) bool #56345
@ -271,17 +271,17 @@ pkg log/slog, method (*LevelVar) MarshalText() ([]uint8, error) #56345
pkg log/slog, method (*LevelVar) Set(Level) #56345 pkg log/slog, method (*LevelVar) Set(Level) #56345
pkg log/slog, method (*LevelVar) String() string #56345 pkg log/slog, method (*LevelVar) String() string #56345
pkg log/slog, method (*LevelVar) UnmarshalText([]uint8) error #56345 pkg log/slog, method (*LevelVar) UnmarshalText([]uint8) error #56345
pkg log/slog, method (*Logger) DebugCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, method (*Logger) DebugContext(context.Context, string, ...interface{}) #61200
pkg log/slog, method (*Logger) Debug(string, ...interface{}) #56345 pkg log/slog, method (*Logger) Debug(string, ...interface{}) #56345
pkg log/slog, method (*Logger) Enabled(context.Context, Level) bool #56345 pkg log/slog, method (*Logger) Enabled(context.Context, Level) bool #56345
pkg log/slog, method (*Logger) ErrorCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, method (*Logger) ErrorContext(context.Context, string, ...interface{}) #61200
pkg log/slog, method (*Logger) Error(string, ...interface{}) #56345 pkg log/slog, method (*Logger) Error(string, ...interface{}) #56345
pkg log/slog, method (*Logger) Handler() Handler #56345 pkg log/slog, method (*Logger) Handler() Handler #56345
pkg log/slog, method (*Logger) InfoCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, method (*Logger) InfoContext(context.Context, string, ...interface{}) #61200
pkg log/slog, method (*Logger) Info(string, ...interface{}) #56345 pkg log/slog, method (*Logger) Info(string, ...interface{}) #56345
pkg log/slog, method (*Logger) LogAttrs(context.Context, Level, string, ...Attr) #56345 pkg log/slog, method (*Logger) LogAttrs(context.Context, Level, string, ...Attr) #56345
pkg log/slog, method (*Logger) Log(context.Context, Level, string, ...interface{}) #56345 pkg log/slog, method (*Logger) Log(context.Context, Level, string, ...interface{}) #56345
pkg log/slog, method (*Logger) WarnCtx(context.Context, string, ...interface{}) #56345 pkg log/slog, method (*Logger) WarnContext(context.Context, string, ...interface{}) #61200
pkg log/slog, method (*Logger) Warn(string, ...interface{}) #56345 pkg log/slog, method (*Logger) Warn(string, ...interface{}) #56345
pkg log/slog, method (*Logger) WithGroup(string) *Logger #56345 pkg log/slog, method (*Logger) WithGroup(string) *Logger #56345
pkg log/slog, method (*Logger) With(...interface{}) *Logger #56345 pkg log/slog, method (*Logger) With(...interface{}) *Logger #56345

View File

@ -174,9 +174,9 @@ argument, as do their corresponding top-level functions.
Although the convenience methods on Logger (Info and so on) and the Although the convenience methods on Logger (Info and so on) and the
corresponding top-level functions do not take a context, the alternatives ending corresponding top-level functions do not take a context, the alternatives ending
in "Ctx" do. For example, in "Context" do. For example,
slog.InfoCtx(ctx, "message") slog.InfoContext(ctx, "message")
It is recommended to pass a context to an output method if one is available. It is recommended to pass a context to an output method if one is available.

View File

@ -168,8 +168,8 @@ func (l *Logger) Debug(msg string, args ...any) {
l.log(nil, LevelDebug, msg, args...) l.log(nil, LevelDebug, msg, args...)
} }
// DebugCtx logs at LevelDebug with the given context. // DebugContext logs at LevelDebug with the given context.
func (l *Logger) DebugCtx(ctx context.Context, msg string, args ...any) { func (l *Logger) DebugContext(ctx context.Context, msg string, args ...any) {
l.log(ctx, LevelDebug, msg, args...) l.log(ctx, LevelDebug, msg, args...)
} }
@ -178,8 +178,8 @@ func (l *Logger) Info(msg string, args ...any) {
l.log(nil, LevelInfo, msg, args...) l.log(nil, LevelInfo, msg, args...)
} }
// InfoCtx logs at LevelInfo with the given context. // InfoContext logs at LevelInfo with the given context.
func (l *Logger) InfoCtx(ctx context.Context, msg string, args ...any) { func (l *Logger) InfoContext(ctx context.Context, msg string, args ...any) {
l.log(ctx, LevelInfo, msg, args...) l.log(ctx, LevelInfo, msg, args...)
} }
@ -188,8 +188,8 @@ func (l *Logger) Warn(msg string, args ...any) {
l.log(nil, LevelWarn, msg, args...) l.log(nil, LevelWarn, msg, args...)
} }
// WarnCtx logs at LevelWarn with the given context. // WarnContext logs at LevelWarn with the given context.
func (l *Logger) WarnCtx(ctx context.Context, msg string, args ...any) { func (l *Logger) WarnContext(ctx context.Context, msg string, args ...any) {
l.log(ctx, LevelWarn, msg, args...) l.log(ctx, LevelWarn, msg, args...)
} }
@ -198,8 +198,8 @@ func (l *Logger) Error(msg string, args ...any) {
l.log(nil, LevelError, msg, args...) l.log(nil, LevelError, msg, args...)
} }
// ErrorCtx logs at LevelError with the given context. // ErrorContext logs at LevelError with the given context.
func (l *Logger) ErrorCtx(ctx context.Context, msg string, args ...any) { func (l *Logger) ErrorContext(ctx context.Context, msg string, args ...any) {
l.log(ctx, LevelError, msg, args...) l.log(ctx, LevelError, msg, args...)
} }
@ -250,8 +250,8 @@ func Debug(msg string, args ...any) {
Default().log(nil, LevelDebug, msg, args...) Default().log(nil, LevelDebug, msg, args...)
} }
// DebugCtx calls Logger.DebugCtx on the default logger. // DebugContext calls Logger.DebugContext on the default logger.
func DebugCtx(ctx context.Context, msg string, args ...any) { func DebugContext(ctx context.Context, msg string, args ...any) {
Default().log(ctx, LevelDebug, msg, args...) Default().log(ctx, LevelDebug, msg, args...)
} }
@ -260,8 +260,8 @@ func Info(msg string, args ...any) {
Default().log(nil, LevelInfo, msg, args...) Default().log(nil, LevelInfo, msg, args...)
} }
// InfoCtx calls Logger.InfoCtx on the default logger. // InfoContext calls Logger.InfoContext on the default logger.
func InfoCtx(ctx context.Context, msg string, args ...any) { func InfoContext(ctx context.Context, msg string, args ...any) {
Default().log(ctx, LevelInfo, msg, args...) Default().log(ctx, LevelInfo, msg, args...)
} }
@ -270,8 +270,8 @@ func Warn(msg string, args ...any) {
Default().log(nil, LevelWarn, msg, args...) Default().log(nil, LevelWarn, msg, args...)
} }
// WarnCtx calls Logger.WarnCtx on the default logger. // WarnContext calls Logger.WarnContext on the default logger.
func WarnCtx(ctx context.Context, msg string, args ...any) { func WarnContext(ctx context.Context, msg string, args ...any) {
Default().log(ctx, LevelWarn, msg, args...) Default().log(ctx, LevelWarn, msg, args...)
} }
@ -280,8 +280,8 @@ func Error(msg string, args ...any) {
Default().log(nil, LevelError, msg, args...) Default().log(nil, LevelError, msg, args...)
} }
// ErrorCtx calls Logger.ErrorCtx on the default logger. // ErrorContext calls Logger.ErrorContext on the default logger.
func ErrorCtx(ctx context.Context, msg string, args ...any) { func ErrorContext(ctx context.Context, msg string, args ...any) {
Default().log(ctx, LevelError, msg, args...) Default().log(ctx, LevelError, msg, args...)
} }

View File

@ -395,14 +395,14 @@ func TestContext(t *testing.T) {
f func(context.Context, string, ...any) f func(context.Context, string, ...any)
wantLevel Level wantLevel Level
}{ }{
{l.DebugCtx, LevelDebug}, {l.DebugContext, LevelDebug},
{l.InfoCtx, LevelInfo}, {l.InfoContext, LevelInfo},
{l.WarnCtx, LevelWarn}, {l.WarnContext, LevelWarn},
{l.ErrorCtx, LevelError}, {l.ErrorContext, LevelError},
{DebugCtx, LevelDebug}, {DebugContext, LevelDebug},
{InfoCtx, LevelInfo}, {InfoContext, LevelInfo},
{WarnCtx, LevelWarn}, {WarnContext, LevelWarn},
{ErrorCtx, LevelError}, {ErrorContext, LevelError},
} { } {
h.clear() h.clear()
ctx := context.WithValue(context.Background(), "L", test.wantLevel) ctx := context.WithValue(context.Background(), "L", test.wantLevel)