MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / EncodeEntry

Method EncodeEntry

internal/logger/zap/zap.go:34–64  ·  view source on GitHub ↗

implementing only EncodeEntry

(entry zapcore.Entry, fields []zapcore.Field)

Source from the content-addressed store, hash-verified

32
33// implementing only EncodeEntry
34func (e *prependEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error) {
35 // new log buffer
36 buf := e.pool.Get()
37 blue := color.New(color.BgBlue)
38 red := color.New(color.BgRed)
39
40 coloredPrefix := blue.Sprint("[BRICKSLLM]")
41 if entry.Level != zap.InfoLevel {
42 coloredPrefix = red.Sprint("[BRICKSLLM]")
43 }
44
45 buf.AppendString(coloredPrefix)
46 buf.AppendString(" ")
47 buf.AppendString(e.toAtalasPrefix(entry.Level))
48 buf.AppendString(" | ")
49 buf.AppendString(time.Now().Format(time.RFC3339))
50 buf.AppendString(" | ")
51
52 // calling the embedded encoder's EncodeEntry to keep the original encoding format
53 consolebuf, err := e.Encoder.EncodeEntry(entry, fields)
54 if err != nil {
55 return nil, err
56 }
57
58 // just write the output into your own buffer
59 _, err = buf.Write(consolebuf.Bytes())
60 if err != nil {
61 return nil, err
62 }
63 return buf, nil
64}
65
66func (e *prependEncoder) toAtalasPrefix(lvl zapcore.Level) string {
67 switch lvl {

Callers

nothing calls this directly

Calls 3

toAtalasPrefixMethod · 0.95
WriteMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected