From 18847f6b166626a2b87337f476c19fee3df5d9f2 Mon Sep 17 00:00:00 2001 From: efron licht Date: Thu, 8 Feb 2024 16:34:40 -0800 Subject: [PATCH] delete! --- compat.go | 50 -------------------------------------------------- log_test.go | 6 ++++-- 2 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 compat.go diff --git a/compat.go b/compat.go deleted file mode 100644 index 1170a54..0000000 --- a/compat.go +++ /dev/null @@ -1,50 +0,0 @@ -// the compat.go file contains functions that are provided for compatibility with the old logrus-based logging. -// in general, you should prefer using the new structured logging functions in this package instead of the functions in this file. -package rplog - -import ( - "context" - "fmt" - "runtime/debug" -) - -// Infof logs at LevelInfo with the given context, initializing the logger if necessary. -// -// Deprecated: prefer using Info directly and adding structured data to the log instead of using this function. -// This function is provided to make it easier to migrate from ourold logrus-based logging. -func Infof(ctx context.Context, msg string, args ...any) { Info(ctx, fmt.Sprintf(msg, args...)) } - -// Debugf logs at LevelDebug as though by fmt.Sprintf, initializing the logger if necessary. -// -// Deprecated: prefer using Debug directly and adding structured data to the log instead of using this function. -// This function is provided to make it easier to migrate from ourold logrus-based logging. -func Debugf(ctx context.Context, msg string, args ...any) { Debug(ctx, fmt.Sprintf(msg, args...)) } - -// Errorf logs at LevelError as though by fmt.Sprintf, initializing the logger if necessary. -// -// Deprecated: prefer using Error directly and adding structured data to the log instead of using this function. -// This function is provided to make it easier to migrate from ourold logrus-based logging. -func Errorf(ctx context.Context, msg string, args ...any) { Error(ctx, fmt.Sprintf(msg, args...)) } - -// Warnf logs at LevelWarn as though by fmt.Sprintf, initializing the logger if necessary. -// -// Deprecated: prefer using Warn directly and adding structured data to the log instead of using this function. -// This function is provided to make it easier to migrate from ourold logrus-based logging. -func Warnf(ctx context.Context, msg string, args ...any) { Warn(ctx, fmt.Sprintf(msg, args...)) } - -// Panic logs at error level and then panics with the given message. -// The stack trace is included in the log. -// Try not to use this function, as it is generally better to return an error instead of panicking. -func Panic(ctx context.Context, msg string) { - stack := debug.Stack() - lg := Log() - lg.ErrorContext(ctx, msg, "stack", string(stack)) - panic(msg) -} - -// Panicf logs at error level and then panics with the given message, formatted as though by fmt.Sprintf. -// The stack trace is included in the log. -// Try not to use this function, as it is generally better to return an error instead of panicking. -// -// Deprecated: prefer using Panic directly and adding structured data to the log instead of using this function. -func Panicf(ctx context.Context, msg string, args ...any) { Panic(ctx, fmt.Sprintf(msg, args...)) } diff --git a/log_test.go b/log_test.go index 809602e..f4d0796 100644 --- a/log_test.go +++ b/log_test.go @@ -1,10 +1,12 @@ package rplog import ( - "context" + "log/slog" + "os" "testing" ) func TestLog(t *testing.T) { - Error(context.TODO(), "hi") + Init(nil, os.Stderr) + slog.Error("hi") }