DefiantLabs / cosmos-tax-cli

An opensource cosmos tax tool!
https://defiantlabs.net
Apache License 2.0
25 stars 7 forks source link

change client to use zero log #169

Closed danbryan closed 1 year ago

danbryan commented 1 year ago

switch this to zero log, allow for pretty print

image

davidkonigsberg commented 1 year ago

The client code is already using the same logger for all of the logs it generates.

That said, the client uses gin a go-based web framework to handle most of the actual work, and this has its own logger.

Looking at the docs, it looks like we can tweak how gin does its log formatting, but I don't think we can get it to do the pretty printing.

Here are what I considered to be the best options:

@danbryan @KyleMoser What do you think?

danbryan commented 1 year ago

@davidkonigsberg Doesn't it uses both gin and the standard log package. Do these these log events get processed via gin?

https://github.com/DefiantLabs/cosmos-tax-cli-private/blob/main/client/client.go#L26 https://github.com/DefiantLabs/cosmos-tax-cli-private/blob/main/client/client.go#L29 https://github.com/DefiantLabs/cosmos-tax-cli-private/blob/main/client/client.go#L32 ... https://github.com/DefiantLabs/cosmos-tax-cli-private/blob/main/client/client.go#L80

davidkonigsberg commented 1 year ago

All of those logs are from before the zero logger gets configured. We don't have zero logger until we inject the zerologger stuff from the config.

It may be possible to use the logger before it is configured, but we will just get the default behavior for those logs until the logger does get configured lower down in the code.

davidkonigsberg commented 1 year ago

Btw, I think the above solution is a good compromise and should be easy/trivial to implement, just wanted to get on the same page for it before I do it.

davidkonigsberg commented 1 year ago

I have updated the logs to use an unconfigured zero logger if it fails before startup. Gonna also try to get Gin to format its logs like zero logger...

davidkonigsberg commented 1 year ago

ohh, I might actually be able to inject our logger into gin using their middleware functionality!