Debuggable Class Reference
The Debuggable class is designed to provide subclasses a configurable console logging capability with the ability to customize the console output based on the level of information desired.
- class configparserenhanced.Debuggable.Debuggable[source]
Bases:
objectAdds some debugging capabilities to subclasses.
A helper class that implements some helpers for things like conditional messages based on a debug level. Generally, the higher the
debug_levelthe more verbose/detailed the messages will be.Note
Normal operation of codes will have a
debug_levelof 0, which would not print out extra debugging information.- property debug_level: int
The debug level of the class.
The
debug_levelis used by various functions to control the level of detail provided during an execution. Values should be positive and range from 0 to intmax, where the higher the value the more detailed the information is.- Returns:
The
debug_levelsetting. If none has been set, the default of 0 is used.- Return type:
int
- debug_message(debug_level, message, end='\n', useprefix=True)[source]
Optionally prints a message based on the
debug_levelsetting.A simple wrapper to
print()which optionally prints out a message based on the currentdebug_level. Ifdebug_level > 0, then an annotation is prepended to the message that indicates what level of debugging triggers this message.If
debug_level > 0, we will also force a stdout flush once the command has completed.- Parameters:
debug_level (int) – Sets the debug level requirement of this message. If
self.debug_level <= debug_level, then this message will be printed. If this paramter is 0 then we do not prepend the debug level annotation to the message so that it will appear the same as a basicprint()message.message (str) – This is the message that will be printed.
end (str) – This allows us to override the line-ending.
useprefix (bool) – If enabled and
debug_level > 0, then a prefix of[D-{debug_level}]will be prepended to the message to indicate thedebug_levelthat triggers this message.