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.
26 lines
598 B
Go
26 lines
598 B
Go
3 years ago
|
package mon
|
||
|
|
||
|
import (
|
||
|
"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(name, method string, startTime time.Duration, err error) {
|
||
|
duration := timex.Since(startTime)
|
||
|
if err != nil {
|
||
|
logx.WithDuration(duration).Infof("mongo(%s) - %s - fail(%s)", name, method, err.Error())
|
||
|
} else {
|
||
|
logx.WithDuration(duration).Infof("mongo(%s) - %s - ok", name, method)
|
||
|
}
|
||
|
}
|