Package XPyLIB :: Module xlogging :: Class IndentFormatter
[hide private]
[frames] | no frames]

Class IndentFormatter

source code

logging.Formatter --+
                    |
           object --+
                    |
                   IndentFormatter

Formatter with indentation level support.

Instance of this class exists only in one exemplar. For other requests of new instance returned already existing.

Level indentation is specific for each threads separately (if thread library available, otherwase used only common indentation level for all threads).

Instance Methods [hide private]
 
__init__(self, fmt=None, datefmt=None)
Initialize the formatter with specified format strings.
source code
 
format(self, record)
Format the specified record as text.
source code

Inherited from logging.Formatter: converter, formatException, formatTime

Inherited from object: __delattr__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
__new__(cls, *args)
Allow only one exemplar of instance.
source code
 
__init_level()
Initialize level for current thread.
source code
 
__get_level()
Get level for current thread.
source code
 
__set_level(value)
Set level for current thread.
source code
 
__createLock()
Acquire a thread lock for serializing access to the level counter.
source code
 
acquire()
Acquire thread lock.
source code
 
release()
Release thread lock.
source code
 
lvlup()
Increase indentation level.
source code
 
lvldown()
Decrease indentation level.
source code
 
lvlreset()
Reset indentation level to "0".
source code
 
lvlwrap(fun)
Auto level decorator for functions.
source code
 
lvlwraplog(fun, loginst)
Auto level decorator for functions.
source code
Class Variables [hide private]
Instance IndentFormatter __instance = <XPyLIB.xlogging.IndentFormatter object at 0xadd3...
Singular instance.
dict{int,int} or int _level = thread and threading.local() or 0
Indentation level.
  __lock = <_RLock(None, 0)>
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, *args)
Static Method

source code 
Allow only one exemplar of instance. For other calls return existing.
Returns:
a new object with type S, a subtype of T

Overrides: object.__new__

__init__(self, fmt=None, datefmt=None)
(Constructor)

source code 

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument (if omitted, you get the ISO8601 format).
Overrides: logging.Formatter.__init__

format(self, record)

source code 
Format the specified record as text.
Overrides: logging.Formatter.format

lvlwrap(fun)
Static Method

source code 

Auto level decorator for functions.

Call lvlup() befor function call and lvldown() after wrapped function return.
Parameters:
  • fun - Wrapped function. @type func

lvlwraplog(fun, loginst)
Static Method

source code 

Auto level decorator for functions.

Write first 'Call "fun.__name__"' using loginst.dbgtrace(). Also as lvlwrap(). If exception occurs then raise it. If level error tested then write '*** DBG LEVEL ERROR = different' where 'different' is level different. Write last 'Return from "fun.__name__"' using loginst.dbgtrace().
Parameters:
  • fun - Wrapped function. @type func
  • loginst - Logger instance to use for reporting. @type loginst

Class Variable Details [hide private]

__instance

Singular instance.
Type:
Instance IndentFormatter
Value:
None

_level

Indentation level. Dictionary of {thread.id, level} if thread enebled, else level.
Type:
dict{int,int} or int
Value:
thread and threading.local() or 0