mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #5528 from yousong/bugfix/yousong-log-go1.14
gomod: update yunion.io/x/log and refresh vendor
This commit is contained in:
@@ -129,7 +129,7 @@ require (
|
||||
k8s.io/kubernetes v1.16.0
|
||||
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74
|
||||
yunion.io/x/jsonutils v0.0.0-20200303051356-aa609aba0cda
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d
|
||||
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3
|
||||
yunion.io/x/pkg v0.0.0-20200304112442-9dae9351325e
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
yunion.io/x/sqlchemy v0.0.0-20200310015557-9e9a49139db1
|
||||
|
||||
@@ -1111,6 +1111,8 @@ yunion.io/x/jsonutils v0.0.0-20200303051356-aa609aba0cda/go.mod h1:T7kxQJR13+t7z
|
||||
yunion.io/x/log v0.0.0-20190514041436-04ce53b17c6b/go.mod h1:+gauLs73omeJAPlsXcevLsJLKixV+sR/E7WSYTSx1fE=
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d h1:59zrDL7Ft+hDukguJRmLr/Gdu/9V75x+yX99ovZwfaA=
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
|
||||
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3 h1:5Wc5hkB8PtMudmHuzCyok960RuOa9I55imIGrigSdjs=
|
||||
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
|
||||
yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20200302034534-fdf44d54b070/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
|
||||
Vendored
+1
-1
@@ -1015,7 +1015,7 @@ yunion.io/x/executor/client
|
||||
yunion.io/x/executor/server
|
||||
# yunion.io/x/jsonutils v0.0.0-20200303051356-aa609aba0cda
|
||||
yunion.io/x/jsonutils
|
||||
# yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d
|
||||
# yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3
|
||||
yunion.io/x/log
|
||||
yunion.io/x/log/hooks
|
||||
# yunion.io/x/pkg v0.0.0-20200304112442-9dae9351325e
|
||||
|
||||
+12
-3
@@ -149,9 +149,18 @@ func DisableColors() {
|
||||
}
|
||||
|
||||
func AddHookFormatter(logger *logrus.Logger) {
|
||||
pcs := make([]uintptr, 2)
|
||||
runtime.Callers(0, pcs)
|
||||
logrusPackage := hooks.GetPackageName(runtime.FuncForPC(pcs[1]).Name())
|
||||
pcs := make([]uintptr, 1)
|
||||
npcs := runtime.Callers(1, pcs)
|
||||
frames := runtime.CallersFrames(pcs[:npcs])
|
||||
var myName string
|
||||
for {
|
||||
f, more := frames.Next()
|
||||
myName = f.Function
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
logrusPackage := hooks.GetPackageName(myName)
|
||||
logger.Hooks.Add(&hooks.CallerHook{logrusPackage})
|
||||
logger.Formatter = &TextFormatter{
|
||||
TimestampFormat: "060102 15:04:05",
|
||||
|
||||
+4
-26
@@ -44,10 +44,6 @@ type SStructFieldInfo struct {
|
||||
Tags map[string]string
|
||||
}
|
||||
|
||||
func (s *SStructFieldInfo) updateTags(k, v string) {
|
||||
s.Tags[k] = v
|
||||
}
|
||||
|
||||
func (s SStructFieldInfo) deepCopy() *SStructFieldInfo {
|
||||
scopy := SStructFieldInfo{
|
||||
Ignore: s.Ignore,
|
||||
@@ -138,11 +134,11 @@ type SStructFieldValue struct {
|
||||
type SStructFieldValueSet []SStructFieldValue
|
||||
|
||||
func FetchStructFieldValueSet(dataValue reflect.Value) SStructFieldValueSet {
|
||||
return fetchStructFieldValueSet(dataValue, false, nil)
|
||||
return fetchStructFieldValueSet(dataValue, false)
|
||||
}
|
||||
|
||||
func FetchStructFieldValueSetForWrite(dataValue reflect.Value) SStructFieldValueSet {
|
||||
return fetchStructFieldValueSet(dataValue, true, nil)
|
||||
return fetchStructFieldValueSet(dataValue, true)
|
||||
}
|
||||
|
||||
type sStructFieldInfoMap map[string]SStructFieldInfo
|
||||
@@ -186,7 +182,7 @@ func fetchStructFieldInfos(dataType reflect.Type) sStructFieldInfoMap {
|
||||
return smap
|
||||
}
|
||||
|
||||
func fetchStructFieldValueSet(dataValue reflect.Value, allocatePtr bool, tags map[string]string) SStructFieldValueSet {
|
||||
func fetchStructFieldValueSet(dataValue reflect.Value, allocatePtr bool) SStructFieldValueSet {
|
||||
fields := SStructFieldValueSet{}
|
||||
dataType := dataValue.Type()
|
||||
fieldInfos := fetchCacheStructFieldInfos(dataType)
|
||||
@@ -222,8 +218,7 @@ func fetchStructFieldValueSet(dataValue reflect.Value, allocatePtr bool, tags ma
|
||||
// different from how encoding/json handles struct
|
||||
// field of interface type.
|
||||
if fv.Kind() == reflect.Struct && sf.Type != gotypes.TimeType {
|
||||
anonymousTags := utils.TagMap(sf.Tag)
|
||||
subfields := fetchStructFieldValueSet(fv, allocatePtr, anonymousTags)
|
||||
subfields := fetchStructFieldValueSet(fv, allocatePtr)
|
||||
fields = append(fields, subfields...)
|
||||
continue
|
||||
}
|
||||
@@ -236,23 +231,6 @@ func fetchStructFieldValueSet(dataValue reflect.Value, allocatePtr bool, tags ma
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(tags) > 0 {
|
||||
for i := range fields {
|
||||
fieldName := fields[i].Info.MarshalName()
|
||||
for k, v := range tags {
|
||||
target := ""
|
||||
pos := strings.Index(k, "->")
|
||||
if pos > 0 {
|
||||
target = k[:pos]
|
||||
k = k[pos+2:]
|
||||
}
|
||||
if len(target) > 0 && target != fieldName {
|
||||
continue
|
||||
}
|
||||
fields[i].Info.updateTags(k, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -105,7 +105,7 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (UpdateDiffs, error) {
|
||||
nf, _ := fields.GetInterface(k)
|
||||
if c.IsPrimary() {
|
||||
if !gotypes.IsNil(of) && !c.IsZero(of) {
|
||||
primaries[k] = c.ConvertFromValue(of)
|
||||
primaries[k] = of
|
||||
} else if c.IsText() {
|
||||
primaries[k] = ""
|
||||
} else {
|
||||
@@ -113,6 +113,12 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (UpdateDiffs, error) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !gotypes.IsNil(of) {
|
||||
if c.IsPrimary() && !c.IsZero(of) { // skip update primary key
|
||||
primaries[k] = of
|
||||
continue
|
||||
}
|
||||
}
|
||||
nc, ok := c.(*SIntegerColumn)
|
||||
if ok && nc.IsAutoVersion {
|
||||
versionFields = append(versionFields, k)
|
||||
|
||||
Reference in New Issue
Block a user