Open BrendanBenshoof opened 9 years ago
I'd like to take this on. Do you want different levels of debug verbosity (e.g. '--debug=4') or just a single debug command argument (e.g. '--debug')?
That former might be better, but the latter is easier.
I vote for a debug and verbose debug
Verbose debug will require us to figure out what qualifies for each level of verbosity (e.g. 'if debug >= 3 print blah'). Is that something we want to do now? The reason I ask is because I'd like to keep the command arguments to this the same between different language implementations so users will get the same (or as close to the same as possible) output if they give the same command arguments to the program.
Taking that into account I'd say just do a single level debug. If we find we need anything else, we can always create a logging function
As a first pass approach, If the printline has 1 '#' then it is first level debug and if it has '##' (it has been 2 "comment out all the spam passes) then it is level two.
@abrosen agreed. I think just a '--debug' should be good for now. We can always revisit once the code is more "complete".
@BrendanBenshoof how about a single level console debug as @abrosen suggests with logging severity dependent on the number of hash symbols in the print statement (e.g. 1x # is informational, and 2x # is critical)?
Go ahead and setup a debug flag, a global variable (I suggest putting it in the 'errors.py' file, and a function to consider writing a debug log)
so:
errors.debug("This is an error message",level=0)
would look at the current flags and decide if to print or write to a log (that could be an option)
Would a higher "debug level" show more or less messages? could we just use a bit-string al la chmod?
example ideas about 'error levels':
0: assorted "I did a thing" spam on workers and functions 1: acceptable error message (things that happen all the time, failed connections ect) 2: fatal error message 3: normal console message, always print
What's the difference between 0 and 3?
0 would be things that we would just normally print out. Like: "the node has started and has connected!". Essentially error.debug("message",0) would redirect to print("message") but we have a hook there to future proof against other logging solutions.
Lets go back and wrap a lot of commented out print statements with a debug mode command line flag.