Trees | Indices | Help |
|
---|
|
Simple debug module.
Used for fast debugging. You may set debug output into two different streams: outstream and fstream. Preferred assignment for streams is:Function for file output starts with f letter. Initialization of streams (open file) is doing only if calling writing function and stream is not initialized. Before start debug output you can initialize streams you own objects which support write method. Then program exit autocalling shutdown function which close fstream if it was opened. If in program no debug output then streams are not created and file are not opened.
Also you may use indentation level by calling lvlup(), lvldown() and decorators level, wlevel and fwlevel. Indentation level used only in next functions: fwriteln() and writeln(). For tune indentation use levelbodychar, levelendchar, levelwidth.
Debug output example, see _debug):*** DEBUG START *** >456 ..>tst1:test >CALL tst2() ..>tst2 start ..>tst1:from tst2 ..>CALL tst3() ....>tst3 ..>RET from tst3() ..>tst2 end >RET from tst2() >CALL tst2() ..>tst2 start ..>tst1:from tst2 ..>CALL tst3() ....>tst3 ..>RET from tst3() ..>tst2 end >RET from tst2() *** DEBUG END ***
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
None |
|
||
None |
|
||
None |
|
||
None |
|
||
None |
|
||
tuple |
|
||
tuple |
|
||
tuple |
|
||
object or Exception |
|
||
object or Exception |
|
||
object or Exception |
|
||
|
|
|||
stream(file-like object). |
outstream = None Output stream, default is sys.stdout. |
||
stream(file-like object). |
fstream = None Output stream, default is "dbg.log" file into "~/.XPyLIB/logs" directory or sys.stderr if file is not available. |
||
str |
levelbodychar =
Character that fill indentation spaces. |
||
str |
levelendchar =
Character that insert before string output but after level indentation. |
||
int |
levelwidth = 2 Number of indentation characters in one indentation level. |
||
int |
levelerr =
Error message then level indentation is invalid thrn return from wrapped function. |
||
str |
descfuncall =
Function call description. |
||
str |
descfunret =
Function return description. |
||
str |
desceval =
String that prepend to eval expression. |
||
str |
descevalrez =
String that prepend to eval resultat. |
||
str |
descevalexc =
String that prepend to eval exception. |
||
str |
descevalln =
String that added at end of eval output. |
||
int |
_level = 0 Indentation level. |
Imports: sys, atexit, os, functools.wraps
|
Auto level decorator for functions. Call lvlup() befor function call and lvldown() after wrapped function return.
|
Auto level and name decorator for functions. Write first 'Call "fun.__name__"' using fwriteln(). Also as level(). If level error tested then write '*** DBG LEVEL ERROR = different' where 'different' is level different. Write last 'Return from "fun.__name__"' using fwriteln().
|
Auto level and name decorator for functions. Write first 'Call "fun.__name__"' using writeln(). Also as level(). If level error tested then write '*** DBG LEVEL ERROR = different' where 'different' is level different. Write last 'Return from "fun.__name__"' using writeln().
|
Initialize file output stream. Default is "dbg.log" file into "~/.XPyLIB/logs" directory or sys.stderr if file is not available. Where "~" is a user home directory. Path autocreate if need. Mode of dirs is 0660. |
|
|
Note: For work this function will be call fwrite function. |
Note: For work this function will be used fwrite function. |
Note: For work this function will be used write function. |
|
|
|
Write expr, evaluate it and write result to output using fun. Write algorithm:
Then write this function you must get globals() and locals() if you using global or local scope variables into exprwssion. For example see weval. |
Write expr, evaluate it and write result to outstream. Write algorithm:
Then write this function you must get globals() and locals() if you using global or local scope variables into exprwssion. For example: dbg.weval('dir(a)', globals(), locals())
|
Write expr, evaluate it and write result to fstream. Write algorithm:
Then write this function you must get globals() and locals() if you using global or local scope variables into exprwssion. For example: dbg.feval('dir(a)', globals(), locals())
|
Test function. Output to outstream is a next:*** DEBUG START *** >456 ..>tst1:test >CALL tst2() ..>tst2 start ..>tst1:from tst2 ..>CALL tst3() ....>tst3 ..>RET from tst3() ..>tst2 end >RET from tst2() >CALL tst2() ..>tst2 start ..>tst1:from tst2 ..>CALL tst3() ....>tst3 ..>RET from tst3() ..>tst2 end >RET from tst2() arg1arg2> rwrite return: ('arg1', 'arg2') >EVAL: "str(5+6)" > ER="11" > > weval return: 11 >CALL tst4() >RET from tst4() >Exception OK *** DEBUG END *** |
|
fstreamOutput stream, default is "dbg.log" file into "~/.XPyLIB/logs" directory or sys.stderr if file is not available. This stream autoclosed then exit from application (used atexit module).
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Mon Dec 1 23:43:15 2008 | http://epydoc.sourceforge.net |