Debian Codegraph @

log.go

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