NewMultiSlogHandler (logging/multihandler.go)

cilium · pkg/logging/multihandler.go · go · Apache-2.0
infra, tag:knn-classified

Creates a slog.Handler that aggregates multiple underlying handlers.

// Source: https://github.com/cilium/cilium | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

package logging

import (
	"context"
	"errors"
	"log/slog"

	"github.com/cilium/cilium/pkg/lock"
)

// NewMultiSlogHandler creates a slog.Handler that supports multiple
// underlying handlers, such as to output text and json.
func NewMultiSlogHandler(handler slog.Handler) *multiSlogHandler {
	return &multiSlogHandler{
		mu:       lock.RWMutex{},
		handlers: []slog.Handler{handler},
	}
}

type multiSlogHandler struct {
	mu       lock.RWMutex
	handlers []slog.Handler
}

func (i *multiSlogHandler) Enabled(ctx context.Contex

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key