Repository navigation
Expand file tree
/
Copy patherror.go
More file actions
55 lines (48 loc) · 1.61 KB
/
Copy patherror.go
File metadata and controls
55 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package log
import (
"context"
"log/slog"
)
// Error logs an error-level message using the global logger.
func Error(args ...any) {
if !levelEnabled(slog.LevelError) {
return
}
msg, attrs := validateArgs(args...)
std.Error(msg, attrs...)
}
// ErrorC logs an error-level message with context using the global logger.
// ctx: The context for the log entry..
func ErrorC(ctx context.Context, args ...interface{}) {
if !levelEnabled(slog.LevelError) {
return
}
msg, attrs := validateArgs(args...)
std.ErrorContext(ctx, msg, attrs...)
}
// Panic logs a panic-level message using the global logger and then panics.
func Panic(args ...any) {
msg, attrs := validateArgs(args...)
std.Panic(msg, attrs...)
}
// PanicC logs a panic-level message with context using the global logger and then panics.
// ctx: The context for the log entry.
func PanicC(ctx context.Context, args ...any) {
msg, attrs := validateArgs(args...)
std.PanicContext(ctx, msg, attrs...)
}
// Fatal logs a fatal-level message using the global logger and then calls os.Exit(1).
// Like os.Exit, it does not run deferred functions, so flush telemetry and
// close resources before calling it.
func Fatal(args ...any) {
msg, attrs := validateArgs(args...)
std.Fatal(msg, attrs...)
}
// FatalC logs a fatal-level message with context using the global logger and then calls os.Exit(1).
// Like os.Exit, it does not run deferred functions, so flush telemetry and
// close resources before calling it.
// ctx: The context for the log entry.
func FatalC(ctx context.Context, args ...any) {
msg, attrs := validateArgs(args...)
std.FatalContext(ctx, msg, attrs...)
}