Bumps the minor-and-patch group with 9 updates: | Package | From | To | | --- | --- | --- | | [github.com/nats-io/nats-server/v2](https://github.com/nats-io/nats-server) | `2.14.4` | `2.14.5` | | [github.com/nats-io/nats.go](https://github.com/nats-io/nats.go) | `1.52.0` | `1.53.1` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.32.0` | `2.32.1` | | [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) | `1.9.4` | `1.10.0` | | [golang.org/x/crypto](https://github.com/golang/crypto) | `0.54.0` | `0.55.0` | | [golang.org/x/image](https://github.com/golang/image) | `0.44.0` | `0.45.0` | | [golang.org/x/net](https://github.com/golang/net) | `0.57.0` | `0.58.0` | | [golang.org/x/text](https://github.com/golang/text) | `0.40.0` | `0.41.0` | | google.golang.org/protobuf | `1.36.11` | `1.36.12` | Updates `github.com/nats-io/nats-server/v2` from 2.14.4 to 2.14.5 - [Release notes](https://github.com/nats-io/nats-server/releases) - [Changelog](https://github.com/nats-io/nats-server/blob/main/RELEASES.md) - [Commits](https://github.com/nats-io/nats-server/compare/v2.14.4...v2.14.5) Updates `github.com/nats-io/nats.go` from 1.52.0 to 1.53.1 - [Release notes](https://github.com/nats-io/nats.go/releases) - [Commits](https://github.com/nats-io/nats.go/compare/v1.52.0...v1.53.1) Updates `github.com/onsi/ginkgo/v2` from 2.32.0 to 2.32.1 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.32.0...v2.32.1) Updates `github.com/sirupsen/logrus` from 1.9.4 to 1.10.0 - [Release notes](https://github.com/sirupsen/logrus/releases) - [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md) - [Commits](https://github.com/sirupsen/logrus/compare/v1.9.4...v1.10.0) Updates `golang.org/x/crypto` from 0.54.0 to 0.55.0 - [Commits](https://github.com/golang/crypto/compare/v0.54.0...v0.55.0) Updates `golang.org/x/image` from 0.44.0 to 0.45.0 - [Commits](https://github.com/golang/image/compare/v0.44.0...v0.45.0) Updates `golang.org/x/net` from 0.57.0 to 0.58.0 - [Commits](https://github.com/golang/net/compare/v0.57.0...v0.58.0) Updates `golang.org/x/text` from 0.40.0 to 0.41.0 - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.40.0...v0.41.0) Updates `google.golang.org/protobuf` from 1.36.11 to 1.36.12 --- updated-dependencies: - dependency-name: github.com/nats-io/nats-server/v2 dependency-version: 2.14.5 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch - dependency-name: github.com/nats-io/nats.go dependency-version: 1.53.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: github.com/onsi/ginkgo/v2 dependency-version: 2.32.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch - dependency-name: github.com/sirupsen/logrus dependency-version: 1.10.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/crypto dependency-version: 0.55.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/image dependency-version: 0.45.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/net dependency-version: 0.58.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: golang.org/x/text dependency-version: 0.41.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-and-patch - dependency-name: google.golang.org/protobuf dependency-version: 1.36.12 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-and-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
92 lines
2.8 KiB
Go
92 lines
2.8 KiB
Go
package logrus
|
|
|
|
import "time"
|
|
|
|
const (
|
|
// defaultTimestampFormat is the layout used to format entry timestamps
|
|
// when a formatter has not specified a custom TimestampFormat.
|
|
// It follows time.RFC3339 and is applied unless timestamps are disabled.
|
|
defaultTimestampFormat = time.RFC3339
|
|
|
|
// defaultFields is the number of commonly included predefined log entry fields
|
|
// (msg, level, time). It is used as a capacity hint when constructing
|
|
// intermediate collections during formatting (for example, the fixed key list).
|
|
//
|
|
// It does not include the optional "logrus_error", "func", or "file" fields.
|
|
defaultFields = 3
|
|
)
|
|
|
|
// Default key names for the default fields
|
|
const (
|
|
FieldKeyMsg = "msg"
|
|
FieldKeyLevel = "level"
|
|
FieldKeyTime = "time"
|
|
FieldKeyLogrusError = "logrus_error"
|
|
FieldKeyFunc = "func"
|
|
FieldKeyFile = "file"
|
|
)
|
|
|
|
// Formatter is implemented by types that format log entries. It receives an
|
|
// [*Entry], which contains:
|
|
//
|
|
// - entry.Message: the message passed to logging methods such as [Info], [Warn], [Error]
|
|
// - entry.Time: the timestamp
|
|
// - entry.Level: the log level
|
|
//
|
|
// Additional fields added with [WithField] or [WithFields] are available in
|
|
// [Entry.Data]. Format should return the formatted log entry as a byte slice,
|
|
// which is written to [Logger.Out].
|
|
type Formatter interface {
|
|
Format(*Entry) ([]byte, error)
|
|
}
|
|
|
|
// This is to not silently overwrite `time`, `msg`, `func` 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, reportCaller bool) {
|
|
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)
|
|
}
|
|
|
|
logrusErrKey := fieldMap.resolve(FieldKeyLogrusError)
|
|
if l, ok := data[logrusErrKey]; ok {
|
|
data["fields."+logrusErrKey] = l
|
|
delete(data, logrusErrKey)
|
|
}
|
|
|
|
// If reportCaller is not set, 'func' will not conflict.
|
|
if reportCaller {
|
|
funcKey := fieldMap.resolve(FieldKeyFunc)
|
|
if l, ok := data[funcKey]; ok {
|
|
data["fields."+funcKey] = l
|
|
}
|
|
fileKey := fieldMap.resolve(FieldKeyFile)
|
|
if l, ok := data[fileKey]; ok {
|
|
data["fields."+fileKey] = l
|
|
}
|
|
}
|
|
}
|