You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/core/stores/mon/util.go

28 lines
644 B
Go

package mon
import (
"context"
"strings"
"time"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/timex"
)
const mongoAddrSep = ","
// FormatAddr formats mongo hosts to a string.
func FormatAddr(hosts []string) string {
return strings.Join(hosts, mongoAddrSep)
}
func logDuration(ctx context.Context, name, method string, startTime time.Duration, err error) {
duration := timex.Since(startTime)
logger := logx.WithContext(ctx).WithDuration(duration)
if err != nil {
logger.Infof("mongo(%s) - %s - fail(%s)", name, method, err.Error())
} else {
logger.Infof("mongo(%s) - %s - ok", name, method)
}
}