Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
logging.LogRecord Class Reference
Inheritance diagram for logging.LogRecord:
Inheritance graph
[legend]
Collaboration diagram for logging.LogRecord:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __str__
def getMessage

Public Attributes

 name
 msg
 args
 levelname
 levelno
 pathname
 filename
 module
 exc_info
 exc_text
 stack_info
 lineno
 funcName
 created
 msecs
 relativeCreated
 thread
 threadName
 processName
 process
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

A LogRecord instance represents an event being logged.

LogRecord instances are created every time something is logged. They
contain all the information pertinent to the event being logged. The
main information passed in is in msg and args, which are combined
using str(msg) % args to create the message field of the record. The
record also includes information such as when the record was created,
the source line where the logging call was made, and any exception
information to be logged.

Definition at line 228 of file __init__.py.


Constructor & Destructor Documentation

def logging.LogRecord.__init__ (   self,
  name,
  level,
  pathname,
  lineno,
  msg,
  args,
  exc_info,
  func = None,
  sinfo = None,
  kwargs 
)
Initialize a logging record with interesting information.

Definition at line 241 of file __init__.py.

00241 
00242                  msg, args, exc_info, func=None, sinfo=None, **kwargs):
00243         """
00244         Initialize a logging record with interesting information.
00245         """
00246         ct = time.time()
00247         self.name = name
00248         self.msg = msg
00249         #
00250         # The following statement allows passing of a dictionary as a sole
00251         # argument, so that you can do something like
00252         #  logging.debug("a %(a)d b %(b)s", {'a':1, 'b':2})
00253         # Suggested by Stefan Behnel.
00254         # Note that without the test for args[0], we get a problem because
00255         # during formatting, we test to see if the arg is present using
00256         # 'if self.args:'. If the event being logged is e.g. 'Value is %d'
00257         # and if the passed arg fails 'if self.args:' then no formatting
00258         # is done. For example, logger.warn('Value is %d', 0) would log
00259         # 'Value is %d' instead of 'Value is 0'.
00260         # For the use case of passing a dictionary, this should not be a
00261         # problem.
00262         if args and len(args) == 1 and isinstance(args[0], dict) and args[0]:
00263             args = args[0]
00264         self.args = args
00265         self.levelname = getLevelName(level)
00266         self.levelno = level
00267         self.pathname = pathname
00268         try:
00269             self.filename = os.path.basename(pathname)
00270             self.module = os.path.splitext(self.filename)[0]
00271         except (TypeError, ValueError, AttributeError):
00272             self.filename = pathname
00273             self.module = "Unknown module"
00274         self.exc_info = exc_info
00275         self.exc_text = None      # used to cache the traceback text
00276         self.stack_info = sinfo
00277         self.lineno = lineno
00278         self.funcName = func
00279         self.created = ct
00280         self.msecs = (ct - int(ct)) * 1000
00281         self.relativeCreated = (self.created - _startTime) * 1000
00282         if logThreads and thread:
00283             self.thread = thread.get_ident()
00284             self.threadName = threading.current_thread().name
00285         else:
00286             self.thread = None
00287             self.threadName = None
00288         if not logMultiprocessing:
00289             self.processName = None
00290         else:
00291             self.processName = 'MainProcess'
00292             mp = sys.modules.get('multiprocessing')
00293             if mp is not None:
00294                 # Errors may occur if multiprocessing has not finished loading
00295                 # yet - e.g. if a custom import hook causes third-party code
00296                 # to run when multiprocessing calls import. See issue 8200
00297                 # for an example
00298                 try:
00299                     self.processName = mp.current_process().name
00300                 except StandardError:
00301                     pass
00302         if logProcesses and hasattr(os, 'getpid'):
00303             self.process = os.getpid()
00304         else:
00305             self.process = None

Here is the caller graph for this function:


Member Function Documentation

def logging.LogRecord.__str__ (   self)

Definition at line 306 of file __init__.py.

00306 
00307     def __str__(self):
00308         return '<LogRecord: %s, %s, %s, %s, "%s">'%(self.name, self.levelno,
00309             self.pathname, self.lineno, self.msg)

Return the message for this LogRecord.

Return the message for this LogRecord after merging any user-supplied
arguments with the message.

Definition at line 310 of file __init__.py.

00310 
00311     def getMessage(self):
00312         """
00313         Return the message for this LogRecord.
00314 
00315         Return the message for this LogRecord after merging any user-supplied
00316         arguments with the message.
00317         """
00318         msg = str(self.msg)
00319         if self.args:
00320             msg = msg % self.args
00321         return msg
00322 
00323 #
00324 #   Determine which class to use when instantiating log records.
#

Member Data Documentation

Definition at line 263 of file __init__.py.

Definition at line 278 of file __init__.py.

Definition at line 273 of file __init__.py.

Definition at line 274 of file __init__.py.

Definition at line 268 of file __init__.py.

Definition at line 277 of file __init__.py.

Definition at line 264 of file __init__.py.

Definition at line 265 of file __init__.py.

Definition at line 276 of file __init__.py.

Definition at line 269 of file __init__.py.

Definition at line 279 of file __init__.py.

Definition at line 247 of file __init__.py.

Definition at line 246 of file __init__.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 266 of file __init__.py.

Definition at line 302 of file __init__.py.

Definition at line 288 of file __init__.py.

Definition at line 280 of file __init__.py.

Definition at line 275 of file __init__.py.

Definition at line 282 of file __init__.py.

Definition at line 283 of file __init__.py.


The documentation for this class was generated from the following file: