taurus.core.util.log
This module contains a set of useful logging elements based on python’s
logging
system.
Classes
- class CriticalIt(showargs=False, showret=False)[source]
Specialization of LogIt for critical level messages. Example:
from taurus.core.util.log import Logger, CriticalIt class Example(Logger): @CriticalIt() def go(self): print("Hello world")
See also
- class DebugIt(showargs=False, showret=False)[source]
Specialization of LogIt for debug level messages. Example:
from taurus.core.util.log import Logger, DebugIt class Example(Logger): @DebugIt() def go(self): print("Hello world")
See also
- class ErrorIt(showargs=False, showret=False)[source]
Specialization of LogIt for error level messages. Example:
from taurus.core.util.log import Logger, ErrorIt class Example(Logger): @ErrorIt() def go(self): print("Hello world")
See also
- class InfoIt(showargs=False, showret=False)[source]
Specialization of LogIt for info level messages. Example:
from taurus.core.util.log import Logger, InfoIt class Example(Logger): @InfoIt() def go(self): print("Hello world")
See also
- class LogExceptHook(hook_to=None, name=None, level=40)[source]
A callable class that acts as an excepthook that logs the exception in the python logging system.
- Parameters:
- class LogIt(level=10, showargs=False, showret=False, col_limit=0)[source]
A function designed to be a decorator of any method of a Logger subclass. The idea is to log the entrance and exit of any decorated method of a Logger subclass.
Example:
from taurus.core.util.log import Logger, LogIt class Example(Logger): @LogIt(Logger.Debug) def go(self): print("Hello world")
This will generate two log messages of Debug level, one before the function go is called and another when go finishes. Example output:
MainThread DEBUG 2010-11-15 15:36:11,440 Example: -> go Hello world of mine MainThread DEBUG 2010-11-15 15:36:11,441 Example: <- go
This decorator can receive two optional arguments showargs and showret which are set to False by default. Enabling them will had verbose infomation about the parameters and return value. The following example:
from taurus.core.uti.log import Logger, LogIt class Example(Logger): @LogIt(Logger.Debug, showargs=True, showret=True) def go(self, msg): msg = "Hello world",msg print(msg) return msg
would generate an output like:
MainThread DEBUG 2010-11-15 15:42:02,353 Example: -> go('of mine',) Hello world of mine MainThread DEBUG 2010-11-15 15:42:02,353 Example: <- go = Hello world of mine
Note
it may happen that in these examples that the output of the method appears before or after the log messages. This is because log messages are, by default, written to the stardard error while the print message inside the go method outputs to the standard ouput. On many systems these two targets are not synchronized.
- class MemoryLogHandler(capacity=1000)[source]
An experimental log handler that stores temporary records in memory. When flushed it passes the records to another handler
- class TraceIt(showargs=False, showret=False)[source]
Specialization of LogIt for trace level messages. Example:
from taurus.core.util.log import Logger, TraceIt class Example(Logger): @TraceIt() def go(self): print("Hello world")
See also
- class WarnIt(showargs=False, showret=False)[source]
Specialization of LogIt for warn level messages. Example:
from taurus.core.util.log import Logger, WarnIt class Example(Logger): @WarnIt() def go(self): print("Hello world")
See also
Functions
- _log(level, msg, *args, **kw)
- deprecation_decorator(func=None, alt=None, rel=None, dbg_msg=None)[source]
decorator to mark methods as deprecated
Variables
- taurus4_deprecation