InitLogger (mlog/init.go)

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

Initializes and configures zap logger with file and stdout options.

// 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 (
	"os"
	"path/filepath"
	"strings"
	"sync/atomic"

	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
	"go.uber.org/zap/zaptest"
	"gopkg.in/natefinch/lumberjack.v2"

	"github.com/milvus-io/milvus/pkg/v3/util/merr"
)

var globalP, globalS, globalCleanup atomic.Value

// InitLogger initializes a zap logger.
func InitLogger(cfg *Config, opts ...Option) (*zap.Logger, *ZapProperties, error) {
	var outputs []zapcore.WriteSyncer
	if len(cfg.File.Filename) > 0 {
		lg, err := initFileLog(&cfg.File)
		if err != nil {
			return nil, nil, err
		}
		outputs = append(outputs, zapcore.

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

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

Get a free API key