package main

import (
	"go.uber.org/zap"
)

func main() {
	logger, _ := zap.NewProduction()
	defer logger.Sync()

	// 1. 获取 Sugar Logger
	sugar := logger.Sugar()

	// 2. 使用格式化字符串（类似 fmt.Printf）
	sugar.Infof("User %s logged in with ID %d", "alice", 123)
	sugar.Warnf("Low disk space: %d MB available", 500)
	sugar.Errorf("Failed to connect to %s:%d", "localhost", 3306)

	// 3. 使用键值对
	sugar.Infow("User logged in",
		"username", "alice",
		"user_id", 123,
		"is_admin", true,
	)

	// 4. 简洁日志
	sugar.Info("Simple info message")
	sugar.Warn("Simple warn message")
}
