Skip to content

Commit

Permalink
add explicit initialization of fields of structures in log/
Browse files Browse the repository at this point in the history
  • Loading branch information
kozyrev-m committed Apr 23, 2024
1 parent 64786ca commit 04e6850
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions log/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,5 +498,10 @@ func internalDriver(l Logger, d trace.Detailer) trace.Driver { //nolint:gocyclo
}
}
},
OnWith: nil,
OnPoolNew: nil,
OnPoolRelease: nil,
OnConnPark: nil,
OnBalancerClusterDiscoveryAttempt: nil,
}
}
18 changes: 18 additions & 0 deletions log/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ func String(k, v string) Field {
ftype: StringType,
key: k,
vstr: v,
vint: 0,
vany: nil,
}
}

Expand All @@ -201,6 +203,8 @@ func Int(k string, v int) Field {
ftype: IntType,
key: k,
vint: int64(v),
vstr: "",
vany: nil,
}
}

Expand All @@ -209,6 +213,8 @@ func Int64(k string, v int64) Field {
ftype: Int64Type,
key: k,
vint: v,
vstr: "",
vany: nil,
}
}

Expand All @@ -225,6 +231,8 @@ func Bool(key string, value bool) Field {
ftype: BoolType,
key: key,
vint: vint,
vstr: "",
vany: nil,
}
}

Expand All @@ -234,6 +242,8 @@ func Duration(key string, value time.Duration) Field {
ftype: DurationType,
key: key,
vint: value.Nanoseconds(),
vstr: "",
vany: nil,
}
}

Expand All @@ -243,6 +253,8 @@ func Strings(key string, value []string) Field {
ftype: StringsType,
key: key,
vany: value,
vint: 0,
vstr: "",
}
}

Expand All @@ -252,6 +264,8 @@ func NamedError(key string, value error) Field {
ftype: ErrorType,
key: key,
vany: value,
vint: 0,
vstr: "",
}
}

Expand All @@ -266,6 +280,8 @@ func Any(key string, value interface{}) Field {
ftype: AnyType,
key: key,
vany: value,
vint: 0,
vstr: "",
}
}

Expand All @@ -280,6 +296,8 @@ func Stringer(key string, value fmt.Stringer) Field {
ftype: StringerType,
key: key,
vany: value,
vint: 0,
vstr: "",
}
}

Expand Down
4 changes: 3 additions & 1 deletion log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type simpleLoggerOption interface {
func Default(w io.Writer, opts ...simpleLoggerOption) *defaultLogger {
l := &defaultLogger{
coloring: false,
logQuery: false,
minLevel: INFO,
clock: clockwork.NewRealClock(),
w: w,
Expand Down Expand Up @@ -104,7 +105,8 @@ type wrapper struct {

func wrapLogger(l Logger, opts ...Option) *wrapper {
ll := &wrapper{
logger: l,
logQuery: false,
logger: l,
}
for _, opt := range opts {
if opt != nil {
Expand Down
1 change: 1 addition & 0 deletions log/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,5 +649,6 @@ func internalQuery(
}
}
},
OnPoolChange: nil,
}
}

0 comments on commit 04e6850

Please sign in to comment.