mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-08-03 04:15:15 +03:00
Fix clash log API not respecting subscribed level
This commit is contained in:
@@ -111,23 +111,13 @@ type observableLogger struct {
|
|||||||
|
|
||||||
func (l *observableLogger) Log(ctx context.Context, level Level, args []any) {
|
func (l *observableLogger) Log(ctx context.Context, level Level, args []any) {
|
||||||
level = OverrideLevelFromContext(level, ctx)
|
level = OverrideLevelFromContext(level, ctx)
|
||||||
if level > l.level && l.platformWriter == nil {
|
if level > l.level && l.platformWriter == nil && !l.needObservable {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nowTime := time.Now()
|
nowTime := time.Now()
|
||||||
if level <= l.level {
|
if l.needObservable {
|
||||||
if l.needObservable {
|
message, messageSimple := l.formatter.FormatWithSimple(ctx, level, l.tag, F.ToString(args...), nowTime)
|
||||||
message, messageSimple := l.formatter.FormatWithSimple(ctx, level, l.tag, F.ToString(args...), nowTime)
|
if level <= l.level {
|
||||||
if level == LevelPanic {
|
|
||||||
panic(message)
|
|
||||||
}
|
|
||||||
l.writer.Write([]byte(message))
|
|
||||||
if level == LevelFatal {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
l.subscriber.Emit(Entry{level, messageSimple})
|
|
||||||
} else {
|
|
||||||
message := l.formatter.Format(ctx, level, l.tag, F.ToString(args...), nowTime)
|
|
||||||
if level == LevelPanic {
|
if level == LevelPanic {
|
||||||
panic(message)
|
panic(message)
|
||||||
}
|
}
|
||||||
@@ -136,6 +126,16 @@ func (l *observableLogger) Log(ctx context.Context, level Level, args []any) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
l.subscriber.Emit(Entry{level, messageSimple})
|
||||||
|
} else if level <= l.level {
|
||||||
|
message := l.formatter.Format(ctx, level, l.tag, F.ToString(args...), nowTime)
|
||||||
|
if level == LevelPanic {
|
||||||
|
panic(message)
|
||||||
|
}
|
||||||
|
l.writer.Write([]byte(message))
|
||||||
|
if level == LevelFatal {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if l.platformWriter != nil {
|
if l.platformWriter != nil {
|
||||||
l.platformWriter.WriteMessage(level, l.platformFormatter.Format(ctx, level, l.tag, F.ToString(args...), nowTime))
|
l.platformWriter.WriteMessage(level, l.platformFormatter.Format(ctx, level, l.tag, F.ToString(args...), nowTime))
|
||||||
|
|||||||
Reference in New Issue
Block a user