RFC: Rethink logging to be more usefull for the user #151
Labels
No labels
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: ungleich-public/cdist#151
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: asteven
-v is basically non-existent. But would be the most important logging
-vv is to verbose. We use it to show a trace of code flow.
-vvv (aka debug) is very verbose, close to useless imho.
I propose to change our logging as follows:
Resources
https://stackoverflow.com/a/5278006
Custom log levels in python
Created by: darko-poljak
Branch better-logging merged to master.
Created by: darko-poljak
@asteven @telmich I redefined cdist logging facility. Take a look: https://github.com/ungleich/cdist/compare/master...darko-poljak:better-logging
If you have no remarks then we can continue with cleaning messages and message levels.
Created by: darko-poljak
@asteven As it seems most logging frameworks use TRACE < DEBUG.
SLF4J, Logback, log4j, Apache Commons Logging, Log4Net, NLog, apache httpd as an application example, as mentioned in comment in above reference and for example in https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels.
In my opinion tracing execution of each step is finer-grained than debug messages.
I agree with the last proposed log levels.
Created by: asteven
What about:
ERROR and WARNING would always be printed unless explicitly silenced by -q/--quiet.
Created by: asteven
@darko-poljak Who said TRACE is finer-grained than DEBUG? There's no law that dictates what log levels are called.
I based the names and order on https://stackoverflow.com/a/5278006 just because it's the most complete, well-founded example I found.
But I don't care that much about the names. Having 4 different/usable logging levels is what I'm after.
Looking at the current logging output:
Most of those INFO's are actually there to follow the code flow as it runs. For me TRACE is the best name for this. INFO would be natural/logical for the messages that actually INFORM the user about something usefull: e.g. hey dude: we just changed the state of your file /tmp/foobar on host some.target.host
If I run the same in debug mode I get 1000 lines of output. For 2 objects.
... several more Local mkdir's
... 170 more lines Linking ...
... again 30 lines of Linking
... another 380 lines of Linking
... and another 300 or so lines of Linking emulator
and another 500 lines or so for remote rmdir/mkdir transfer, exec ...
All the 'Linking foo to bar' and 'linking emulator' messages are just useless noise.
We have tests to verify that the code works. If it can link one emulator the same code will also be able to link the other 500. And if it fails for one, we have exceptions for that.
All the Remote run: 'long string of code' are also just noise. Sometimes usefull to have to troubleshoot a very specific problem. But for a initial debug - useless.
Created by: asteven
@telmich there is nothing wrong with creating custom logging levels. What the end user cares about is INFO (the new one) and ERROR. Everything else is basically just for us/internal use. We can do whatever we want with our logging. After all this is totally self contained within cdist.
Created by: telmich
ok with me
Created by: darko-poljak
@asteven @telmich The following?
ERROR = 40 (cdist level -1)
WARNING = 30 (cdist level 0, default - for simplicity for now WARNING and ERROR are united in lowest and default level)
INFO = 20 (cdist level 1, -v)
DEBUG = 10 (cdist level 2, -vv)
TRACE = 5 (cdist level 3, -vvv)
Created by: darko-poljak
@telmich There is no TRACE log level. I would also remove VERBOSE_INFO and add only TRACE.
Created by: telmich
Just my 2 cent: if python already defines 5 log levels, I suggest to use them.
I don't see an advantage in creating custom levels - prove me wrong, but simplicity usually wins.
Created by: darko-poljak
@asteven
I would do it in this order, to go with convention (e.g. TRACE is finer-grained than DEBUG).
I also took inspiration from nping
https://nmap.org/book/nping-man-output-options.html
ERROR = 40 (cdist level -1, -v-1)
WARNING = 30 (cdist level 0, default, -v0)
INFO = 20 (cdist level 1, -v, -v1)
VERBOSE_INFO = 15 (cdist level 2, -vv, -v2)
DEBUG = 10 (cdist level 3, -vvv, -v3)
TRACE = 5 (cdist level 4, -vvvv, -v4)
So we can change -v parameter to
-v[<level>]
.-v alone increases level to INFO, and so on.
Or leave it as is with no way to turn WARNING off and only go with ERROR.
But I know only for one WARN currently in use: if lookup for host name and fqdn fails or
has no result.