Back to index

python3.2  3.2.2
Namespaces | Classes | Functions | Variables
logging Namespace Reference

Namespaces

namespace  config
namespace  handlers

Classes

class  LogRecord
class  PercentStyle
class  StrFormatStyle
class  StringTemplateStyle

Functions

def currentframe
def getLevelName
def addLevelName
def _checkLevel
def _acquireLock
def _releaseLock
def setLogRecordFactory
def getLogRecordFactory
def makeLogRecord

Variables

list __all__
 codecs = None
 thread = None
string __author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
string __status__ = "production"
string __version__ = "0.5.1.2"
string __date__ = "07 February 2010"
string _srcfile = "logging%s__init__%s"
tuple _startTime = time.time()
int raiseExceptions = 1
int logThreads = 1
int logMultiprocessing = 1
int logProcesses = 1
int CRITICAL = 50
 FATAL = CRITICAL
int ERROR = 40
int WARNING = 30
 WARN = WARNING
int INFO = 20
int DEBUG = 10
int NOTSET = 0
dictionary _levelNames
tuple _lock = threading.RLock()
 _logRecordFactory = LogRecord

Function Documentation

def logging._acquireLock ( ) [private]
Acquire the module-level lock for serializing access to shared data.

This should be released with _releaseLock().

Definition at line 208 of file __init__.py.

00208 
00209 def _acquireLock():
00210     """
00211     Acquire the module-level lock for serializing access to shared data.
00212 
00213     This should be released with _releaseLock().
00214     """
00215     if _lock:
00216         _lock.acquire()

Here is the caller graph for this function:

def logging._checkLevel (   level) [private]

Definition at line 179 of file __init__.py.

00179 
00180 def _checkLevel(level):
00181     if isinstance(level, int):
00182         rv = level
00183     elif str(level) == level:
00184         if level not in _levelNames:
00185             raise ValueError("Unknown level: %r" % level)
00186         rv = _levelNames[level]
00187     else:
00188         raise TypeError("Level not an integer or a valid string: %r" % level)
00189     return rv
00190 
00191 #---------------------------------------------------------------------------
00192 #   Thread-related stuff
00193 #---------------------------------------------------------------------------
00194 
00195 #
00196 #_lock is used to serialize access to shared data structures in this module.
00197 #This needs to be an RLock because fileConfig() creates and configures
00198 #Handlers, and so might arbitrary user threads. Since Handler code updates the
00199 #shared dictionary _handlers, it needs to acquire the lock. But if configuring,
00200 #the lock would already have been acquired - so we need an RLock.
00201 #The same argument applies to Loggers and Manager.loggerDict.
#

Here is the caller graph for this function:

def logging._releaseLock ( ) [private]
Release the module-level lock acquired by calling _acquireLock().

Definition at line 217 of file __init__.py.

00217 
00218 def _releaseLock():
00219     """
00220     Release the module-level lock acquired by calling _acquireLock().
00221     """
00222     if _lock:
00223         _lock.release()
00224 
00225 #---------------------------------------------------------------------------
00226 #   The logging record
00227 #---------------------------------------------------------------------------

Here is the caller graph for this function:

def logging.addLevelName (   level,
  levelName 
)
Associate 'levelName' with 'level'.

This is used when converting levels to text during message formatting.

Definition at line 166 of file __init__.py.

00166 
00167 def addLevelName(level, levelName):
00168     """
00169     Associate 'levelName' with 'level'.
00170 
00171     This is used when converting levels to text during message formatting.
00172     """
00173     _acquireLock()
00174     try:    #unlikely to cause an exception, but you never know...
00175         _levelNames[level] = levelName
00176         _levelNames[levelName] = level
00177     finally:
00178         _releaseLock()

Here is the call graph for this function:

Here is the caller graph for this function:

Return the frame object for the caller's stack frame.

Definition at line 71 of file __init__.py.

00071 
00072 def currentframe():
00073     """Return the frame object for the caller's stack frame."""
00074     try:
00075         raise Exception
00076     except:
00077         return sys.exc_info()[2].tb_frame.f_back

def logging.getLevelName (   level)
Return the textual representation of logging level 'level'.

If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,
INFO, DEBUG) then you get the corresponding string. If you have
associated levels with names using addLevelName then the name you have
associated with 'level' is returned.

If a numeric value corresponding to one of the defined levels is passed
in, the corresponding string representation is returned.

Otherwise, the string "Level %s" % level is returned.

Definition at line 150 of file __init__.py.

00150 
00151 def getLevelName(level):
00152     """
00153     Return the textual representation of logging level 'level'.
00154 
00155     If the level is one of the predefined levels (CRITICAL, ERROR, WARNING,
00156     INFO, DEBUG) then you get the corresponding string. If you have
00157     associated levels with names using addLevelName then the name you have
00158     associated with 'level' is returned.
00159 
00160     If a numeric value corresponding to one of the defined levels is passed
00161     in, the corresponding string representation is returned.
00162 
00163     Otherwise, the string "Level %s" % level is returned.
00164     """
00165     return _levelNames.get(level, ("Level %s" % level))

Return the factory to be used when instantiating a log record.

Definition at line 337 of file __init__.py.

00337 
00338 def getLogRecordFactory():
00339     """
00340     Return the factory to be used when instantiating a log record.
00341     """
00342 
00343     return _logRecordFactory

def logging.makeLogRecord (   dict)
Make a LogRecord whose attributes are defined by the specified dictionary,
This function is useful for converting a logging event received over
a socket connection (which is sent as a dictionary) into a LogRecord
instance.

Definition at line 344 of file __init__.py.

00344 
00345 def makeLogRecord(dict):
00346     """
00347     Make a LogRecord whose attributes are defined by the specified dictionary,
00348     This function is useful for converting a logging event received over
00349     a socket connection (which is sent as a dictionary) into a LogRecord
00350     instance.
00351     """
00352     rv = _logRecordFactory(None, None, "", 0, "", (), None, None)
00353     rv.__dict__.update(dict)
00354     return rv
00355 
00356 #---------------------------------------------------------------------------
00357 #   Formatter classes and functions
00358 #---------------------------------------------------------------------------

Here is the caller graph for this function:

def logging.setLogRecordFactory (   factory)
Set the factory to be used when instantiating a log record.

:param factory: A callable which will be called to instantiate
a log record.

Definition at line 327 of file __init__.py.

00327 
00328 def setLogRecordFactory(factory):
00329     """
00330     Set the factory to be used when instantiating a log record.
00331 
00332     :param factory: A callable which will be called to instantiate
00333     a log record.
00334     """
00335     global _logRecordFactory
00336     _logRecordFactory = factory

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
00002            'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO',
00003            'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'NullHandler',
00004            'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig',
00005            'captureWarnings', 'critical', 'debug', 'disable', 'error',
00006            'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
00007            'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
00008            'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']

Definition at line 29 of file __init__.py.

string logging.__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"

Definition at line 49 of file __init__.py.

string logging.__date__ = "07 February 2010"

Definition at line 52 of file __init__.py.

string logging.__status__ = "production"

Definition at line 50 of file __init__.py.

Definition at line 51 of file __init__.py.

Initial value:
00001 {
00002     CRITICAL : 'CRITICAL',
00003     ERROR : 'ERROR',
00004     WARNING : 'WARNING',
00005     INFO : 'INFO',
00006     DEBUG : 'DEBUG',
00007     NOTSET : 'NOTSET',
00008     'CRITICAL' : CRITICAL,
00009     'ERROR' : ERROR,
00010     'WARN' : WARNING,
00011     'WARNING' : WARNING,
00012     'INFO' : INFO,
00013     'DEBUG' : DEBUG,
00014     'NOTSET' : NOTSET,
00015 }

Definition at line 134 of file __init__.py.

Definition at line 203 of file __init__.py.

Definition at line 325 of file __init__.py.

tuple logging._srcfile = "logging%s__init__%s"

Definition at line 63 of file __init__.py.

tuple logging._startTime = time.time()

Definition at line 91 of file __init__.py.

Definition at line 41 of file __init__.py.

Definition at line 125 of file __init__.py.

Definition at line 131 of file __init__.py.

Definition at line 127 of file __init__.py.

Definition at line 126 of file __init__.py.

Definition at line 130 of file __init__.py.

Definition at line 107 of file __init__.py.

Definition at line 112 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 132 of file __init__.py.

Definition at line 97 of file __init__.py.

Definition at line 47 of file __init__.py.

Definition at line 129 of file __init__.py.

Definition at line 128 of file __init__.py.