Comments (8)
+1 here, it should not be forced.
from logrus.
Aye, could be an option like ForceColors
.
from logrus.
yeah, something like SortFields
from logrus.
I'll happily accept a patch
from logrus.
I looked in to this and in order to do this we probably need to add another WithFields*-method since logrus.Fields{} is of type map[string]interface{}, which by nature is "random".
I have been playing around with making WithField() either take a ...interface{} and thus be able to handle multiple key/value pairs (which we could keep sorted) or to just add a WithFieldList() not to make people confused with the name being singular.
Any input on what would feel most natural?
from logrus.
Fixed in 538395b
from logrus.
The solution isn't this easy since entry.Data is of type Fields (map) and maps are random by nature.
Code:
logrus.SetFormatter(&logrus.TextFormatter{DisableSorting: true})
logrus.WithFields(logrus.Fields{"one": 1, "two": 2, "three": 3, "four": 4}).Info("one")
logrus.WithFields(logrus.Fields{"two": 2, "one": 1, "four": 4, "three": 3}).Info("two")
logrus.WithFields(logrus.Fields{"three": 3, "four": 4, "two": 2, "one": 1}).Info("three")
Output of run 1:
INFO[0000] one one=1 two=2 three=3 four=4
INFO[0000] two one=1 four=4 three=3 two=2
INFO[0000] three one=1 three=3 four=4 two=2
Output of run 2:
INFO[0000] one one=1 two=2 three=3 four=4
INFO[0000] two two=2 one=1 four=4 three=3
INFO[0000] three one=1 three=3 four=4 two=2
Notice how they now are random instead of sorted. We would have to change from the map type to a slice in order to implement this for real. Where they align correctly to their input is just pure luck.
from logrus.
Yes, that's what I expected, most aggregators are fine with that—I didn't do a full reimplementation with a slice. I'd happily accept a patch that does.
from logrus.
Related Issues (20)
- Info requested: How to buffer messages and release at the end HOT 2
- Vulnerability of dependency "gopkg.in/yaml.v3" HOT 2
- Logrus potential DOS - Please open a CVE for issue #1370 to encourage users to patch HOT 3
- Feature: Add slog compatibility layer HOT 5
- logrus+lumberjackrus, After the old log is deleted, the hard drive will not be released, HOT 2
- Vulnerability: gopkg.in/yaml.v3 CVE-2022-28948 HOT 2
- Bazel compilation failling HOT 2
- Question: Any way to view the value of a field from a logrus.FieldLogger? HOT 2
- How to apply colours for a custom log format? HOT 2
- How to safely change Logger.Out on the fly? HOT 2
- How should I position my problem? HOT 2
- Cut a new release with wasip1 support? HOT 4
- github.com/interactive-solutions/go-logrus-elasticsearch cannot find HOT 2
- Bump version of stretchr/testify? HOT 3
- Unclear on documentation regarding Hook interface HOT 3
- Please maintain the CHANGELOG HOT 3
- logger.Out.Write's mutex may be unnecessary, when Out is a file fd HOT 2
- Use for range to output two identical logs
- Update stretchr/testify to 1.9.0 to resolve 2 High sev Vulnerabilities found in go yaml lib from current version HOT 4
- Please reopen and fix https://github.com/sirupsen/logrus/issues/972, skipping caller frames HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logrus.