diff --git a/log/logsdk/entry.go b/log/logsdk/entry.go index 1bfa0ec..11e72bc 100644 --- a/log/logsdk/entry.go +++ b/log/logsdk/entry.go @@ -186,7 +186,6 @@ func (entry Entry) log(ctx context.Context, level Level, message string) { return } readonlyEntry := ReadonlyEntry{ - Context: ctx, Fields: newEntry.fields, Message: message, Time: newEntry.time, @@ -202,13 +201,12 @@ func (entry Entry) log(ctx context.Context, level Level, message string) { readonlyEntry.Stack = getStack(newEntry.callerSkip, 32) } for _, processor := range newEntry.logger.getLevelProcessors(level) { - processor.Process(readonlyEntry) + processor.Process(ctx, readonlyEntry) } } // ReadonlyEntry 是日志系统收集到1条日志记录 type ReadonlyEntry struct { - Context context.Context `json:"-"` Caller Frame Stack []Frame Time time.Time diff --git a/log/logsdk/logjson/processor.go b/log/logsdk/logjson/processor.go index 39ad5e4..5447119 100644 --- a/log/logsdk/logjson/processor.go +++ b/log/logsdk/logjson/processor.go @@ -1,6 +1,7 @@ package logjson import ( + "context" "encoding/json" "fmt" "io" @@ -36,7 +37,7 @@ type Processor struct { } // Process 处理日志 -func (processor *Processor) Process(entry logsdk.ReadonlyEntry) { +func (processor *Processor) Process(_ context.Context, entry logsdk.ReadonlyEntry) { m := Entry{ Stack: entry.Stack, Fields: entry.Fields, diff --git a/log/logsdk/processor.go b/log/logsdk/processor.go index 4b85d85..59242b5 100644 --- a/log/logsdk/processor.go +++ b/log/logsdk/processor.go @@ -1,8 +1,10 @@ package logsdk +import "context" + // EntryProcessor 处理日志记录 type EntryProcessor interface { - Process(entry ReadonlyEntry) + Process(ctx context.Context, entry ReadonlyEntry) } type levelProcessors [LevelCount][]EntryProcessor