MCPcopy Index your code
hub / github.com/python/cpython / Handler

Class Handler

Lib/logging/__init__.py:925–1112  ·  view source on GitHub ↗

Handler instances dispatch logging events to specific destinations. The base handler class. Acts as a placeholder which defines the Handler interface. Handlers can optionally use Formatter instances to format records as desired. By default, no formatter is specified; in this case,

Source from the content-addressed store, hash-verified

923
924
925class Handler(Filterer):
926 """
927 Handler instances dispatch logging events to specific destinations.
928
929 The base handler class. Acts as a placeholder which defines the Handler
930 interface. Handlers can optionally use Formatter instances to format
931 records as desired. By default, no formatter is specified; in this case,
932 the 'raw' message as determined by record.message is logged.
933 """
934 def __init__(self, level=NOTSET):
935 """
936 Initializes the instance - basically setting the formatter to None
937 and the filter list to empty.
938 """
939 Filterer.__init__(self)
940 self._name = None
941 self.level = _checkLevel(level)
942 self.formatter = None
943 self._closed = False
944 # Add the handler to the global _handlerList (for cleanup on shutdown)
945 _addHandlerRef(self)
946 self.createLock()
947
948 def get_name(self):
949 return self._name
950
951 def set_name(self, name):
952 with _lock:
953 if self._name in _handlers:
954 del _handlers[self._name]
955 self._name = name
956 if name:
957 _handlers[name] = self
958
959 name = property(get_name, set_name)
960
961 def createLock(self):
962 """
963 Acquire a thread lock for serializing access to the underlying I/O.
964 """
965 self.lock = threading.RLock()
966 _register_at_fork_reinit_lock(self)
967
968 def _at_fork_reinit(self):
969 self.lock._at_fork_reinit()
970
971 def acquire(self):
972 """
973 Acquire the I/O thread lock.
974 """
975 if self.lock:
976 self.lock.acquire()
977
978 def release(self):
979 """
980 Release the I/O thread lock.
981 """
982 if self.lock:

Callers

nothing calls this directly

Calls 1

propertyClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…