MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Handle

Method Handle

logger/handler.go:132–171  ·  view source on GitHub ↗

Handle processes a log record.

(ctx context.Context, r slog.Record)

Source from the content-addressed store, hash-verified

130
131// Handle processes a log record.
132func (h *Handler) Handle(ctx context.Context, r slog.Record) error {
133 buf := newBuffer()
134 defer func() {
135 buf.free()
136 }()
137
138 h.format(r, buf)
139
140 h.mu.Lock()
141 defer h.mu.Unlock()
142
143 var errs []error
144
145 // Write log entry to output
146 if r.Level >= h.config.Level.Level() {
147 _, err := h.out.Write(*buf)
148 if err != nil {
149 errs = append(errs, err)
150 }
151 }
152
153 // Fire hooks
154 for _, hook := range h.hooks {
155 if !hook.Enabled(r.Level) {
156 continue
157 }
158 if err := hook.Fire(ctx, r.Time, r.Level, slices.Clip(*buf)); err != nil {
159 errs = append(errs, err)
160 }
161 }
162
163 // If writing to output or firing hooks returned errors,
164 // join them, write to STDERR, and return
165 if err := h.joinErrors(errs); err != nil {
166 h.writeError(err)
167 return err
168 }
169
170 return nil
171}
172
173// format formats a log record and writes it to the buffer.
174func (h *Handler) format(r slog.Record, buf *buffer) {

Callers 3

closeImgproxyReaderFunction · 0.45
imgproxyReaderSeekFunction · 0.45
imgproxyReaderReadFunction · 0.45

Calls 9

formatMethod · 0.95
joinErrorsMethod · 0.95
writeErrorMethod · 0.95
freeMethod · 0.80
LevelMethod · 0.80
newBufferFunction · 0.70
EnabledMethod · 0.65
FireMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected