mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-18 04:49:55 +00:00
For some reason, `Sirupsen/logrus` was still in `emicklei/go-restful-openapi`: ``` $ git grep Sirupsen vendor/github.com/emicklei/go-restful-openapi/examples/security/api.go: "github.com/Sirupsen/logrus" ``` After running: ``` $ gvt delete github.com/emicklei/go-restful-openapi $ gvt delete github.com/marccarre/go-restful-openapi $ gvt fetch --revision 129557de7d9f2d2ca4a90cd31c379db90a561ad8 --branch lowercase-sirupsen github.com/marccarre/go-restful-openapi 2018/07/23 17:28:40 Fetching: github.com/marccarre/go-restful-openapi 2018/07/23 17:28:42 · Fetching recursive dependency: github.com/emicklei/go-restful-openapi 2018/07/23 17:28:44 ·· Skipping (existing): github.com/go-openapi/spec 2018/07/23 17:28:44 ·· Skipping (existing): github.com/emicklei/go-restful 2018/07/23 17:28:44 ·· Fetching recursive dependency: github.com/Sirupsen/logrus 2018/07/23 17:28:46 ··· Skipping (existing): github.com/sirupsen/logrus 2018/07/23 17:28:46 ··· Skipping (existing): golang.org/x/crypto/ssh/terminal 2018/07/23 17:28:46 ··· Skipping (existing): golang.org/x/sys/unix 2018/07/23 17:28:46 · Skipping (existing): github.com/go-openapi/spec 2018/07/23 17:28:46 · Skipping (existing): github.com/sirupsen/logrus 2018/07/23 17:28:46 · Skipping (existing): github.com/emicklei/go-restful $ rm -fr vendor/github.com/Sirupsen/ $ git reset HEAD vendor/manifest $ git checkout -- vendor/manifest $ gvt delete github.com/sirupsen/logrus $ gvt fetch --tag v1.0.6 github.com/sirupsen/logrus ``` it was gone.
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package logrus
|
|
|
|
import "time"
|
|
|
|
const defaultTimestampFormat = time.RFC3339
|
|
|
|
// The Formatter interface is used to implement a custom Formatter. It takes an
|
|
// `Entry`. It exposes all the fields, including the default ones:
|
|
//
|
|
// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
|
|
// * `entry.Data["time"]`. The timestamp.
|
|
// * `entry.Data["level"]. The level the entry was logged at.
|
|
//
|
|
// Any additional fields added with `WithField` or `WithFields` are also in
|
|
// `entry.Data`. Format is expected to return an array of bytes which are then
|
|
// logged to `logger.Out`.
|
|
type Formatter interface {
|
|
Format(*Entry) ([]byte, error)
|
|
}
|
|
|
|
// This is to not silently overwrite `time`, `msg` and `level` fields when
|
|
// dumping it. If this code wasn't there doing:
|
|
//
|
|
// logrus.WithField("level", 1).Info("hello")
|
|
//
|
|
// Would just silently drop the user provided level. Instead with this code
|
|
// it'll logged as:
|
|
//
|
|
// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
|
//
|
|
// It's not exported because it's still using Data in an opinionated way. It's to
|
|
// avoid code duplication between the two default formatters.
|
|
func prefixFieldClashes(data Fields, fieldMap FieldMap) {
|
|
timeKey := fieldMap.resolve(FieldKeyTime)
|
|
if t, ok := data[timeKey]; ok {
|
|
data["fields."+timeKey] = t
|
|
delete(data, timeKey)
|
|
}
|
|
|
|
msgKey := fieldMap.resolve(FieldKeyMsg)
|
|
if m, ok := data[msgKey]; ok {
|
|
data["fields."+msgKey] = m
|
|
delete(data, msgKey)
|
|
}
|
|
|
|
levelKey := fieldMap.resolve(FieldKeyLevel)
|
|
if l, ok := data[levelKey]; ok {
|
|
data["fields."+levelKey] = l
|
|
delete(data, levelKey)
|
|
}
|
|
}
|