Note that there are some explanatory texts on larger screens.

plurals
  1. POPython indentation \ context level to log prefix length
    primarykey
    data
    text
    <p>my idea is to make context logging scheme as showed on the example below:</p> <pre><code>[ DEBUG] Parsing dialogs files [ DEBUG] ... [DialogGroup_001] [ DEBUG] ...... Indexing dialog xml file [c:\001_dlg.xml] [ DEBUG] ......... dialog [LobbyA] [ DEBUG] ............ speech nodes [3] [ DEBUG] ............... [LobbyA_01] [ DEBUG] ............... [LobbyA_02] [ DEBUG] ............... [LobbyA_03] [ DEBUG] ............ sms nodes [0] [ DEBUG] ......... dialog [LobbyB] [ DEBUG] ............ speech nodes [3] [ DEBUG] ............... [LobbyB_01] [ DEBUG] ............... [LobbyB_02] [ DEBUG] ............... [LobbyB_03] [ DEBUG] ............ sms nodes [0] [ DEBUG] ... [DialogGroup_002] [ DEBUG] ...... Indexing dialog xml file [c:\002_dlg.xml] [ DEBUG] ......... dialog [HighGroundsA] [ DEBUG] ............ speech nodes [3] [ DEBUG] ............... [HighGroundsA_01] [ DEBUG] ............... [HighGroundsA_02] [ DEBUG] ............... [HighGroundsA_03] [ DEBUG] ............ sms nodes [0] </code></pre> <p>At this point, I'm using a Python's logging module with custom, hand-written prefixes when logging, for example:</p> <pre><code>(...) log.debug('') log.debug('Parsing dialogs files') for dlg in defDlgList: log.debug('... [{0}]'.format(dlg)) (...) </code></pre> <p>It's working quite ok, but there are some subtle problems, for example: when logging from inside functions - they may be called from various scopes and prefix length may vary for each call.</p> <p>I'm looking for a elegant and invisible way to establish a length of a '...' prefix automatically for each log. I'd rather avoid passing prefix length as a parameter to each func or setting the lenght using explicit calls, for example:</p> <pre><code>(...) logWrapper.debug('') logWrapper.debug('Parsing dialogs files') for dlg in defDlgList: logWrapper.nextLogLevelBegin() logWrapper.debug('[{0}]'.format(dlg)) logWrapper.nextLogLevelEnd() (...) </code></pre> <p>Is there a way to get the current indentation level from Python's parser or construct a scope sensitive wrapper class for logging?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload