feat: implement scenario-driven sales SOP platform

This commit is contained in:
Eric 1549169735@qq.com
2026-08-06 21:37:29 +08:00
parent 254469ab89
commit de5345607a
84 changed files with 7132 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
package logger
import (
"strings"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func New(environment, service string) (*zap.Logger, error) {
var cfg zap.Config
if strings.EqualFold(environment, "prod") || strings.EqualFold(environment, "production") {
cfg = zap.NewProductionConfig()
cfg.EncoderConfig.TimeKey = "time"
cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
} else {
cfg = zap.NewDevelopmentConfig()
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
}
cfg.OutputPaths = []string{"stdout"}
cfg.ErrorOutputPaths = []string{"stderr"}
log, err := cfg.Build()
if err != nil {
return nil, err
}
return log.With(zap.String("service", service), zap.String("env", environment)), nil
}