|
|
@ -127,8 +127,8 @@ func (entry Entry) Fatal(ctx context.Context, args ...any) {
|
|
|
|
entry.logger.Exit(1)
|
|
|
|
entry.logger.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Panic 输出 LevelPanic 等级的日志,
|
|
|
|
// Panic 输出 LevelPanic 等级的日志后执行 panic,
|
|
|
|
// Panic 不会调用 panic 函数.
|
|
|
|
// 即使 Logger 日志等级高于 LevelPanic 也会 panic.
|
|
|
|
func (entry Entry) Panic(ctx context.Context, args ...any) {
|
|
|
|
func (entry Entry) Panic(ctx context.Context, args ...any) {
|
|
|
|
entry.log(ctx, LevelPanic, fmt.Sprint(args...))
|
|
|
|
entry.log(ctx, LevelPanic, fmt.Sprint(args...))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -170,12 +170,17 @@ func (entry Entry) Fatalf(ctx context.Context, format string, args ...any) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Panicf 格式化输出 LevelPanic 等级的日志,
|
|
|
|
// Panicf 格式化输出 LevelPanic 等级的日志,
|
|
|
|
// Panicf 不会调用 panic 函数.
|
|
|
|
// 即使 Logger 日志等级高于 LevelPanic 也会 panic.
|
|
|
|
func (entry Entry) Panicf(ctx context.Context, format string, args ...any) {
|
|
|
|
func (entry Entry) Panicf(ctx context.Context, format string, args ...any) {
|
|
|
|
entry.log(ctx, LevelPanic, fmt.Sprintf(format, args...))
|
|
|
|
entry.log(ctx, LevelPanic, fmt.Sprintf(format, args...))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (entry Entry) log(ctx context.Context, level Level, message string) {
|
|
|
|
func (entry Entry) log(ctx context.Context, level Level, message string) {
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
|
|
|
|
if level == LevelPanic {
|
|
|
|
|
|
|
|
panic(message)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
newEntry := entry.copy()
|
|
|
|
newEntry := entry.copy()
|
|
|
|
if newEntry.logger.GetLevel() < level {
|
|
|
|
if newEntry.logger.GetLevel() < level {
|
|
|
|
return
|
|
|
|
return
|
|
|
|