Use consisent logging instead of printf everywhere. #185
Comments
I'll take this one today! |
An update: this is partially done, but there are still few places with printf and logrus. |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done This issue now has a funding of 0.1 ETH (114.26 USD @ $1142.63/ETH) attached to it as part of the Tellor-io fund.
|
@krasi-georgiev I would like to take on this but I after reading your suggestions on Gitcoin and reading the Telliot code I would say that instead of changing all commented out fmt.Printf to level.Debug(logger).Log(....) we should decide on each situation what makes sense more sense from the user perspective.
Please correct me if I'm wrong. Thanks! |
yep very true! Also another rule is that of a log happens once at start up it is fine to be info, but if it happens many times in a loop unless it is extremely important in most case this is too much noise and it should be debug. |
@krasi-georgiev Yes, makes sense to not overwhelm the user, but I think that in situations where you want to analyze the logs with a tool, changing behavior can be confusing as that's the only feedback that you have for your analysis, but anyway we will get the right balance I think. I'm going to do some changes here and as I learn more about this project we will find what works for a good user experience. |
once this is done also should add in the same PR some more linting to the makefile like
the 2 etra lines are:
This will enforce that there are no print statements anywhere and also that |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work has been started. These users each claimed they can complete the work by 265 years, 6 months from now. 1) g33kidd has applied to start work (Funders only: approve worker | reject worker). I will take a stab at this, it seemed like an interesting thing to do. Ok thaiquang0602@gmail.com....................... I looked at the code base and the previously mentioned example projects you mentioned. From the examples i've gathered that if the functions using printf dont have a constructor then the logger should be dependency injected into the function itself. If this isnt the case, then i'd like clarification there. And in the main package (telliot/cmd/telliot/main.go) they will be setup using the SetupLogger function from util and passed to either the constructor or injected directly into function (as first parameter). Also looking at the codebase i cant find any commented out printfs, so im assuming you mean printfs in general? Open to discuss this further if i've misunderstood the task RocketCat#3507 I've just checked the repo and it seems some printf-s were replaced (and it helped me to understand how to do it). We still have 10 files with printf-s and I will change that. i could do this, replacing all calls to printf for an implementation of the above mentioned logging package, i could start working on this tomorrow Hi, I guess this would be really good first project to start with. This would be very easy - just find and replace printf to logging and then double checking. I would perform the requested task; replace all current logging with google's golang logger library (quite lightweight: https://github.com/google/logger), and scope each message depending on the context (debug, warning, etc). Learn more on the Gitcoin Issue Details page. |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work for 0.1 ETH (167.47 USD @ $1674.72/ETH) has been submitted by:
|
The codebase has printf in a lot of places which is easy to start with, but when parsing or filtering logs it brings up many problems later on with monitoring and tracing.
a logger should be initialized in the main package and then passed to all package constructors.
This is a very good logging package
github.com/go-kit/kit/log
for an example how to implement look at the thanos or prometheus projects.
all commented-out printf-s can be replaced with debug logs so that these are displayed only when debugging is enabled.
level.Debug(logger).Log("msg", "debug")
Important! Check the project coding guidelines
https://github.com/tellor-io/telliot/blob/master/docs/coding-style-guide.md
The text was updated successfully, but these errors were encountered: