logrus
logrus copied to clipboard
Add optional formatter to writer hook
The changes make hooks.Writer
to accept optional Formatter
which would be used to format the log entries before writing.
Thanks for your contribution. It is interesting indeed. Can you improve the documentation a bit on the hook.Writer class on how to use the new field and what is the expected behaviour when it is not defined ?
@dgsb Added a line about Formatter usage. Hope it helps.
When can we expect this to be merged?
Here's the difference between 'DisableColors' false/true. Why is there such a total change in the formatting?
ESC[33mWARNESC[0m[2020-10-29T15:25:06Z] Shutting things down...
ESC[36mINFOESC[0m[2020-10-29T15:25:06Z] Database closed
time="2020-10-29T15:25:10Z" level=info msg="Connected to RPC server" Host="http://127.0.0.1:18732"
time="2020-10-29T15:25:10Z" level=debug msg="Loaded Network Constants" BlocksPerCycle=2048 BlocksPerRollSnapshot=256 PreservedCycles=3
Expected when DisableColors: false
WARN[2020-10-29T15:25:06Z] Shutting things down...
INFO[2020-10-29T15:25:06Z] Database closed
Seems this is an issue with the formatter itself and not this PR. https://github.com/sirupsen/logrus/blob/d131c24e23baaa812461202af6d7cfa388e2d292/text_formatter.go#L201 I'll open a different issue
Thanks for your contribution @sivachandran
Anything holding this up? Works great for me.
@someburner What's holding this up is that logrus is, unfortunately, a dead project. It says in the README that new features won't be added. You'll have to do like me and run your own fork. Yes, also in the README it says they are not dead, but if you're not adding new features, nor accepting community contributions, you're certainly not an "active" project.