Package rrlog :: Class Log
[hide private]
[frames] | no frames]

Class Log

source code

object --+
         |
        Log

Instances of this are callable and represent the runtime interface for the application.

Instance Methods [hide private]
 
__init__(self, server, on=None, traceOffset=0, msgCountLimit=1000000, stackMax=1, errorHandler=None, catsEnable=None, catsDisable=None, seFilesExclude=None, name=None, extractStack=True)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
logging23_handler(self)
Note that, contrary to the Python logging, the rrlog is not designed/tested for threading.
source code
 
_getCallPath(self, tb, depth)
Returns: path,cfuncname where path = ( (filename,lineno), ...), len >=0 cfuncname is "" if no traceback available, None if no cfuncname exists (log call at module level)
source code
 
_createServerData(self, tb, depth, message, cat, special)
Returns: Tuple for the log server
source code
 
log(self, *args, **kwargs)
REMOVED.
source code
 
on(self) source code
 
off(self) source code
 
__call__(self, message, cat='', special=None, traceDepth=1, **kwargs)
You can provide any kwargs you like.
source code
 
__repr__(self)
repr(x)
source code

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

Instance Variables [hide private]
  stackMax
See __init__, can be modified anytime.
  traceOffset
See __init__, can be modified anytime.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, server, on=None, traceOffset=0, msgCountLimit=1000000, stackMax=1, errorHandler=None, catsEnable=None, catsDisable=None, seFilesExclude=None, name=None, extractStack=True)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • catsEnable - None or list of cat strings, e.g.("E","W",""). (Remember, the empty cat "" is the default.) If a list is specified, only these cats are logged, all other calls are ignored. If None, all cats are enabled.
  • catsDisable - All cats in this list are ignored. Only one of the parameters catsEnable and catsDisable can be specified, not both same time.
  • on - DONT USE ANYMORE. Use catsEnable=() to switch off the log.
  • traceOffset - Adjusts the start point of the logged stack trace. Default == 0. Increase to 1 if you have wrapped the log, otherwise, all stack paths will start with your wrapper function. Too high values are silently adjusted to the highest value possible.
  • stackMax - 0==show no stacktrace, 1==log one stack line (the line where log(...) was called), 2==log two stack lines, and so on. Default: 1 (==log callers line and nothing else.) See also: extractStack parameter.
  • errorHandler - Gets any Exception that occurs while logging. (e.g.a connection failure to the log server) If handler is None: No handling, your application will receive any exception occurring inside the log() call. For convenience, you may provide one of these strings: "stderr","stdout","silent" (case-insensitive). These strings are translated into the appropriate built-in "~ErrorHandler" class.
  • seFilesExclude - Stack Extraction-Excluded Files. None (==nothing to exclude), or a callable that returns True/False when given a filename. When True, the file does NOT appear in the call path. None is acepted instead of False too, just to enable pragmatic ideas like seFilesExclude=re.compile("foo/bar.*").search (which exludes all foo/bar* files). Note: The callers file name (cfn) is never excluded this way, only the rest of the trace may be "censored".
  • name - str, defaults to class name. For individual use (to identify the log object). The log itself does not evaluate it but use it with its __repr__/__str__ method.
  • extractStack - If False, stack extraction is disabled. This improves performance (can be more than twice), but any stack related functionality will not work (e.g.line indention to visualize call hierarchy).
Overrides: object.__init__

logging23_handler(self)

source code 

Note that, contrary to the Python logging, the rrlog is not designed/tested for threading.

Returns:
a Handler for the Python >=2.3 standard logging framework.

_getCallPath(self, tb, depth)

source code 
Parameters:
  • depth - int,log-internal call depth when the traceback was taken.
Returns:
path,cfuncname where path = ( (filename,lineno), ...), len >=0 cfuncname is "" if no traceback available, None if no cfuncname exists (log call at module level)

_createServerData(self, tb, depth, message, cat, special)

source code 
Parameters:
  • depth - int,log-internal call depth when the traceback was taken.
Returns:
Tuple for the log server

log(self, *args, **kwargs)

source code 

REMOVED. There's no log.log() anymore. Use log() instead (i.e. see __call__

Raises:
  • AssertionError - Always

__call__(self, message, cat='', special=None, traceDepth=1, **kwargs)
(Call operator)

source code 

You can provide any kwargs you like. This is sugar for convenience, all kwargs are put into the "special" dict. Same restrictions, see below. Note: kwargs items override items of special dict silently.

Parameters:
  • message - String to be logged
  • cat - application specific category, e.g. "E"=Error,"W"=Warning. Default is "".
  • special - dict-like object (only the items() method is required, delivering a (k,v)-iter); or None. The items of the "special" dict appear in the Jobs at the server side. Custom observers, filters and writers may use these data. Type restrictions: only {str: str|int} is allowed for the dict items (!)
  • traceDepth - Adjusts the starting point of stacktrace logging. Default=1. Typically, you may increase that if you call the log with a wrapping function which should not appear in the logged stacktrace. This adjusts a single call only. See traceOffset in __init__ for a global adjustment.
Returns:
log-client specific message number,starting with 1 (not unique at server side, if multiple log clients are used.)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)