mysql: pin the mysql dependency
This commit is contained in:
+17
-11
@@ -45,22 +45,28 @@ func New(opts *LoggerOptions) Logger {
|
||||
mtx = new(sync.Mutex)
|
||||
}
|
||||
|
||||
return &intLogger{
|
||||
m: mtx,
|
||||
json: opts.JSONFormat,
|
||||
caller: opts.IncludeLocation,
|
||||
name: opts.Name,
|
||||
w: bufio.NewWriter(output),
|
||||
level: level,
|
||||
ret := &intLogger{
|
||||
m: mtx,
|
||||
json: opts.JSONFormat,
|
||||
caller: opts.IncludeLocation,
|
||||
name: opts.Name,
|
||||
timeFormat: TimeFormat,
|
||||
w: bufio.NewWriter(output),
|
||||
level: level,
|
||||
}
|
||||
if opts.TimeFormat != "" {
|
||||
ret.timeFormat = opts.TimeFormat
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// The internal logger implementation. Internal in that it is defined entirely
|
||||
// by this package.
|
||||
type intLogger struct {
|
||||
json bool
|
||||
caller bool
|
||||
name string
|
||||
json bool
|
||||
caller bool
|
||||
name string
|
||||
timeFormat string
|
||||
|
||||
// this is a pointer so that it's shared by any derived loggers, since
|
||||
// those derived loggers share the bufio.Writer as well.
|
||||
@@ -132,7 +138,7 @@ func trimCallerPath(path string) string {
|
||||
|
||||
// Non-JSON logging format function
|
||||
func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{}) {
|
||||
z.w.WriteString(t.Format(TimeFormat))
|
||||
z.w.WriteString(t.Format(z.timeFormat))
|
||||
z.w.WriteByte(' ')
|
||||
|
||||
s, ok := _levelToBracket[level]
|
||||
|
||||
+3
@@ -139,4 +139,7 @@ type LoggerOptions struct {
|
||||
|
||||
// Include file and line information in each log line
|
||||
IncludeLocation bool
|
||||
|
||||
// The time format to use instead of the default
|
||||
TimeFormat string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user