| 1 |
package clog |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"log/slog" |
| 6 |
"os" |
| 7 |
) |
| 8 |
|
| 9 |
|
| 10 |
func Info(msg string, args ...any) { |
| 11 |
wrap(context.Background(), DefaultLogger(), slog.LevelInfo, msg, args...) |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
func InfoContext(ctx context.Context, msg string, args ...any) { |
| 17 |
wrap(ctx, FromContext(ctx), slog.LevelInfo, msg, args...) |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
func Infof(format string, args ...any) { |
| 22 |
wrapf(context.Background(), DefaultLogger(), slog.LevelInfo, format, args...) |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
func InfoContextf(ctx context.Context, format string, args ...any) { |
| 28 |
wrapf(ctx, FromContext(ctx), slog.LevelInfo, format, args...) |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
func Warn(msg string, args ...any) { |
| 33 |
wrap(context.Background(), DefaultLogger(), slog.LevelWarn, msg, args...) |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
func WarnContext(ctx context.Context, msg string, args ...any) { |
| 39 |
wrap(ctx, FromContext(ctx), slog.LevelWarn, msg, args...) |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
func Warnf(format string, args ...any) { |
| 44 |
wrapf(context.Background(), DefaultLogger(), slog.LevelWarn, format, args...) |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
func WarnContextf(ctx context.Context, format string, args ...any) { |
| 50 |
wrapf(ctx, FromContext(ctx), slog.LevelWarn, format, args...) |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
func Error(msg string, args ...any) { |
| 55 |
wrap(context.Background(), DefaultLogger(), slog.LevelError, msg, args...) |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
func ErrorContext(ctx context.Context, msg string, args ...any) { |
| 60 |
wrap(ctx, FromContext(ctx), slog.LevelError, msg, args...) |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
func Errorf(format string, args ...any) { |
| 65 |
wrapf(context.Background(), DefaultLogger(), slog.LevelError, format, args...) |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
func ErrorContextf(ctx context.Context, format string, args ...any) { |
| 70 |
wrapf(ctx, FromContext(ctx), slog.LevelError, format, args...) |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
func Debug(msg string, args ...any) { |
| 75 |
wrap(context.Background(), DefaultLogger(), slog.LevelDebug, msg, args...) |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
func DebugContext(ctx context.Context, msg string, args ...any) { |
| 80 |
wrap(ctx, FromContext(ctx), slog.LevelDebug, msg, args...) |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
func Debugf(format string, args ...any) { |
| 85 |
wrapf(context.Background(), DefaultLogger(), slog.LevelDebug, format, args...) |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
func DebugContextf(ctx context.Context, format string, args ...any) { |
| 91 |
wrapf(ctx, FromContext(ctx), slog.LevelDebug, format, args...) |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
func Fatal(msg string, args ...any) { |
| 96 |
wrap(context.Background(), DefaultLogger(), slog.LevelError, msg, args...) |
| 97 |
os.Exit(1) |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
func FatalContext(ctx context.Context, msg string, args ...any) { |
| 102 |
wrap(ctx, FromContext(ctx), slog.LevelError, msg, args...) |
| 103 |
os.Exit(1) |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
func Fatalf(format string, args ...any) { |
| 108 |
wrapf(context.Background(), DefaultLogger(), slog.LevelError, format, args...) |
| 109 |
os.Exit(1) |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
func FatalContextf(ctx context.Context, format string, args ...any) { |
| 114 |
wrapf(ctx, FromContext(ctx), slog.LevelError, format, args...) |
| 115 |
os.Exit(1) |
| 116 |
} |