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

Method format

logger/handler.go:174–199  ·  view source on GitHub ↗

format formats a log record and writes it to the buffer.

(r slog.Record, buf *buffer)

Source from the content-addressed store, hash-verified

172
173// format formats a log record and writes it to the buffer.
174func (h *Handler) format(r slog.Record, buf *buffer) {
175 groups := h.groups
176
177 // If there are no attributes in the record itself,
178 // remove empty groups from the end
179 if r.NumAttrs() == 0 {
180 for len(groups) > 0 && len(groups[len(groups)-1].attrs) == 0 {
181 groups = groups[:len(groups)-1]
182 }
183 }
184
185 // Format the log record according to the format specified in options
186 switch h.config.Format {
187 case FormatPretty:
188 newFormatterPretty(groups, buf).format(r)
189 case FormatJSON:
190 newFormatterJSON(groups, buf, false).format(r)
191 case FormatGCP:
192 newFormatterJSON(groups, buf, true).format(r)
193 default:
194 newFormatterStructured(groups, buf).format(r)
195 }
196
197 // Add line break after each log entry
198 buf.append('\n')
199}
200
201func (h *Handler) joinErrors(errs []error) error {
202 if len(errs) == 0 {

Callers 2

HandleMethod · 0.95
writeErrorMethod · 0.95

Calls 4

newFormatterPrettyFunction · 0.85
newFormatterJSONFunction · 0.85
newFormatterStructuredFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected