init (mlog/logger.go)

milvus · pkg/mlog/logger.go · go · Apache-2.0
infra, tag:knn-classified

Initializes global Zap logger with OpenTelemetry trace integration for Milvus.

// Source: https://github.com/milvus-io/milvus | 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.
package mlog

import (
	"context"
	"sync/atomic"

	"go.opentelemetry.io/otel/trace"
	"go.uber.org/zap"
)

var (
	// globalLogger is the package-level logger
	globalLogger atomic.Pointer[zap.Logger]

	// nilContextField is added when nil context is passed
	nilContextField = zap.Bool("_ctx_nil", true)
)

func init() {
	logger, props := newStdLogger()
	ReplaceGlobals(logger, props)
}

// initGlobalLogger replaces the global logger with the provided one.
// The caller is responsible for configuring the logger.
// AddCallerSkip(1) is automatically applied.
func initGlobalLogger(logger *zap.Lo

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

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

Get a free API key