-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.go
More file actions
161 lines (131 loc) · 4.04 KB
/
print.go
File metadata and controls
161 lines (131 loc) · 4.04 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package log
import (
"context"
"errors"
"fmt"
"github.com/gogf/gf/v2/os/glog"
)
// Ctx 创建并返回一个带有上下文的 Log 实例。
func Ctx(ctx context.Context) *Log {
return &Log{ctx: ctx, logger: glog.DefaultLogger().Clone()}
}
// Debug 使用默认上下文记录调试信息。
func Debug(args ...any) {
glog.Debug(ctx, args...)
}
// Debugln 使用默认上下文记录调试信息。
func Debugln(args ...any) {
glog.Debug(ctx, args...)
}
// Debugf 使用默认上下文记录调试信息。
func Debugf(format string, args ...any) {
format = trimFormat(format)
glog.Debugf(ctx, format, args...)
}
// Print 使用默认上下文记录信息。
func Print(args ...any) {
glog.Info(ctx, args...)
}
// Println 使用默认上下文记录一行信息。
func Println(args ...any) {
glog.Info(ctx, args...)
}
// Printf 使用默认上下文格式化并记录信息。
func Printf(format string, args ...any) {
format = trimFormat(format)
glog.Infof(ctx, format, args...)
}
// Info 使用默认上下文记录信息。
func Info(args ...any) {
glog.Info(ctx, args...)
}
// Infoln 使用默认上下文记录一行信息。
func Infoln(args ...any) {
glog.Info(ctx, args...)
}
// Infof 使用默认上下文格式化并记录信息。
func Infof(format string, args ...any) {
format = trimFormat(format)
glog.Infof(ctx, format, args...)
}
// Notice 使用默认上下文记录通知信息。
func Notice(args ...any) {
glog.Notice(ctx, args...)
}
// Noticeln 使用默认上下文记录一行通知信息。
func Noticeln(args ...any) {
glog.Notice(ctx, args...)
}
// Noticef 使用默认上下文格式化并记录通知信息。
func Noticef(format string, args ...any) {
format = trimFormat(format)
glog.Noticef(ctx, format, args...)
}
// Fatal 使用默认上下文记录致命错误信息,并终止程序。
func Fatal(args ...any) {
glog.Fatal(ctx, args...)
}
// Fatalln 使用默认上下文记录一行致命错误信息,并终止程序。
func Fatalln(args ...any) {
glog.Fatal(ctx, args...)
}
// Fatalf 使用默认上下文格式化并记录致命错误信息,并终止程序。
func Fatalf(format string, args ...any) {
format = trimFormat(format)
glog.Fatalf(ctx, format, args...)
}
// Panic 使用默认上下文记录恐慌信息,并触发panic。
func Panic(args ...any) {
glog.Panic(ctx, args...)
}
// Panicln 使用默认上下文记录一行恐慌信息,并触发panic。
func Panicln(args ...any) {
glog.Panic(ctx, args...)
}
// Panicf 使用默认上下文格式化并记录恐慌信息,并触发panic。
func Panicf(format string, args ...any) {
format = trimFormat(format)
glog.Panicf(ctx, format, args...)
}
// Critical 使用默认上下文记录严重错误信息。
func Critical(args ...any) {
glog.Critical(ctx, args...)
}
// Criticalln 使用默认上下文记录一行严重错误信息。
func Criticalln(args ...any) {
glog.Critical(ctx, args...)
}
// Criticalf 使用默认上下文格式化并记录严重错误信息。
func Criticalf(format string, args ...any) {
format = trimFormat(format)
glog.Criticalf(ctx, format, args...)
}
// Error 使用默认上下文记录错误信息,并返回错误对象。
func Error(args ...any) error {
glog.Error(ctx, args...)
return errors.New(fmt.Sprint(args...))
}
// Errorln 使用默认上下文记录一行错误信息,并返回错误对象。
func Errorln(args ...any) error {
glog.Error(ctx, args...)
return errors.New(fmt.Sprint(args...))
}
// Errorf 使用默认上下文格式化并记录错误信息,并返回错误对象。
func Errorf(format string, args ...any) error {
format = trimFormat(format)
glog.Errorf(ctx, format, args...)
return fmt.Errorf(format, args...)
}
// Warnln 使用默认上下文记录警告信息。
func Warnln(args ...any) {
glog.Warning(ctx, args...)
}
// Warnf 使用默认上下文格式化并记录警告信息。
func Warnf(format string, args ...any) {
format = trimFormat(format)
glog.Warningf(ctx, format, args...)
}
// Warn 使用默认上下文记录警告信息。
func Warn(args ...any) {
glog.Warning(ctx, args...)
}