logrus icon indicating copy to clipboard operation
logrus copied to clipboard

Add optional formatter to writer hook

Open sivachandran opened this issue 4 years ago • 8 comments

The changes make hooks.Writer to accept optional Formatter which would be used to format the log entries before writing.

sivachandran avatar Sep 29 '20 08:09 sivachandran

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 avatar Sep 30 '20 11:09 dgsb

@dgsb Added a line about Formatter usage. Hope it helps.

sivachandran avatar Oct 01 '20 04:10 sivachandran

When can we expect this to be merged?

utdrmac avatar Oct 29 '20 14:10 utdrmac

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

utdrmac avatar Oct 29 '20 15:10 utdrmac

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

utdrmac avatar Oct 29 '20 15:10 utdrmac

Thanks for your contribution @sivachandran

dgsb avatar Nov 21 '20 18:11 dgsb

Anything holding this up? Works great for me.

someburner avatar Jan 22 '21 23:01 someburner

@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.

utdrmac avatar Jan 23 '21 01:01 utdrmac