(self, name, level, pathname, lineno,
                 msg, args, exc_info, func=None, sinfo=None, **kwargs)
Initialize a logging record with interesting information.
Initialize a logging record with interesting information.
Initialize a logging record with interesting information .
def __init__(self, name, level, pathname, lineno,
                 msg, args, exc_info, func=None, sinfo=None, **kwargs):
        """
        Initialize a logging record with interesting information.
        """
        ct = time.time()
        self.name = name
        self.msg = msg
        #
        # The following statement allows passing of a dictionary as a sole
        # argument, so that you can do something like
        #  logging.debug("a %(a)d b %(b)s", {'a':1, 'b':2})
        # Suggested by Stefan Behnel.
        # Note that without the test for args[0], we get a problem because
        # during formatting, we test to see if the arg is present using
        # 'if self.args:'. If the event being logged is e.g. 'Value is %d'
        # and if the passed arg fails 'if self.args:' then no formatting
        # is done. For example, logger.warning('Value is %d', 0) would log
        # 'Value is %d' instead of 'Value is 0'.
        # For the use case of passing a dictionary, this should not be a
        # problem.
        # Issue #21172: a request was made to relax the isinstance check
        # to hasattr(args[0], '__getitem__'). However, the docs on string
        # formatting still seem to suggest a mapping object is required.
        # Thus, while not removing the isinstance check, it does now look
        # for collections.abc.Mapping rather than, as before, dict.
        if (args and len(args) == 1 and isinstance(args[0], collections.abc.Mapping)
            and args[0]):
            args = args[0]
        self.args = args
        self.levelname = getLevelName(level)
        self.levelno = level
        self.pathname = pathname
        try:
            self.filename = os.path.basename(pathname)
            self.module = os.path.splitext(self.filename)[0]
        except (TypeError, ValueError, AttributeError):
            self.filename = pathname
            self.module = "Unknown module"
        self.exc_info = exc_info
        self.exc_text = None      # used to cache the traceback text
        self.stack_info = sinfo
        self.lineno = lineno
        self.funcName = func
        self.created = ct
        self.msecs = (ct - int(ct)) * 1000
        self.relativeCreated = (self.created - _startTime) * 1000
        if logThreads:
            self.thread = threading.get_ident()
            self.threadName = threading.current_thread().name
        else: # pragma: no cover
            self.thread = None
            self.threadName = None
        if not logMultiprocessing: # pragma: no cover
            self.processName = None
        else:
            self.processName = 'MainProcess'
            mp = sys.modules.get('multiprocessing')
            if mp is not None:
                # Errors may occur if multiprocessing has not finished loading
                # yet - e.g. if a custom import hook causes third-party code
                # to run when multiprocessing calls import. See issue 8200
                # for an example
                try:
                    self.processName = mp.current_process().name
                except Exception: #pragma: no cover
                    pass
        if logProcesses and hasattr(os, 'getpid'):
            self.process = os.getpid()
        else:
            self.process = None
def __init__ ( self , name , level , pathname , lineno , msg , args , exc_info , func = None , sinfo = None , * * kwargs ) : ct = time . time ( ) self . name = name self . msg = msg # # The following statement allows passing of a dictionary as a sole # argument, so that you can do something like #  logging.debug("a %(a)d b %(b)s", {'a':1, 'b':2}) # Suggested by Stefan Behnel. # Note that without the test for args[0], we get a problem because # during formatting, we test to see if the arg is present using # 'if self.args:'. If the event being logged is e.g. 'Value is %d' # and if the passed arg fails 'if self.args:' then no formatting # is done. For example, logger.warning('Value is %d', 0) would log # 'Value is %d' instead of 'Value is 0'. # For the use case of passing a dictionary, this should not be a # problem. # Issue #21172: a request was made to relax the isinstance check # to hasattr(args[0], '__getitem__'). However, the docs on string # formatting still seem to suggest a mapping object is required. # Thus, while not removing the isinstance check, it does now look # for collections.abc.Mapping rather than, as before, dict. if ( args and len ( args ) == 1 and isinstance ( args [ 0 ] , collections . abc . Mapping ) and args [ 0 ] ) : args = args [ 0 ] self . args = args self . levelname = getLevelName ( level ) self . levelno = level self . pathname = pathname try : self . filename = os . path . basename ( pathname ) self . module = os . path . splitext ( self . filename ) [ 0 ] except ( TypeError , ValueError , AttributeError ) : self . filename = pathname self . module = "Unknown module" self . exc_info = exc_info self . exc_text = None # used to cache the traceback text self . stack_info = sinfo self . lineno = lineno self . funcName = func self . created = ct self . msecs = ( ct - int ( ct ) ) * 1000 self . relativeCreated = ( self . created - _startTime ) * 1000 if logThreads : self . thread = threading . get_ident ( ) self . threadName = threading . current_thread ( ) . name else : # pragma: no cover self . thread = None self . threadName = None if not logMultiprocessing : # pragma: no cover self . processName = None else : self . processName = 'MainProcess' mp = sys . modules . get ( 'multiprocessing' ) if mp is not None : # Errors may occur if multiprocessing has not finished loading # yet - e.g. if a custom import hook causes third-party code # to run when multiprocessing calls import. See issue 8200 # for an example try : self . processName = mp . current_process ( ) . name except Exception : #pragma: no cover pass if logProcesses and hasattr ( os , 'getpid' ) : self . process = os . getpid ( ) else : self . process = None