LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.log.log.logContinued.LogHandler Class Reference
Inheritance diagram for lsst.log.log.logContinued.LogHandler:

Public Member Functions

def __init__ (self, level=logging.NOTSET)
 
def handle (self, record)
 
def emit (self, record)
 

Public Attributes

 formatter
 

Detailed Description

Handler for Python logging module that emits to LSST logging.

Parameters
----------
level : `int`
    Level at which to set the this handler.

Notes
-----
If this handler is enabled and `lsst.log` has been configured to use
Python `logging`, the handler will do nothing itself if any other
handler has been registered with the Python logger.  If it does not
think that anything else is handling the message it will attempt to
send the message via a default `~logging.StreamHandler`.  The safest
approach is to configure the logger with an additional handler
(possibly the ROOT logger) if `lsst.log` is to be configured to use
Python logging.

Definition at line 479 of file logContinued.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.log.log.logContinued.LogHandler.__init__ (   self,
  level = logging.NOTSET 
)

Definition at line 499 of file logContinued.py.

499  def __init__(self, level=logging.NOTSET):
500  logging.Handler.__init__(self, level=level)
501  # Format as a simple message because lsst.log will format the
502  # message a second time.
503  self.formatter = logging.Formatter(fmt="%(message)s")
504 

Member Function Documentation

◆ emit()

def lsst.log.log.logContinued.LogHandler.emit (   self,
  record 
)

Definition at line 510 of file logContinued.py.

510  def emit(self, record):
511  if Log.UsePythonLogging:
512  # Do not forward this message to lsst.log since this may cause
513  # a logging loop.
514 
515  # Work out whether any other handler is going to be invoked
516  # for this logger.
517  pylgr = logging.getLogger(record.name)
518 
519  # If another handler is registered that is not LogHandler
520  # we ignore this request
521  if any(not isinstance(h, self.__class__) for h in pylgr.handlers):
522  return
523 
524  # If the parent has handlers and propagation is enabled
525  # we punt as well (and if a LogHandler is involved then we will
526  # ask the same question when we get to it).
527  if pylgr.parent and pylgr.parent.hasHandlers() and pylgr.propagate:
528  return
529 
530  # Force this message to appear somewhere.
531  # If something else should happen then the caller should add a
532  # second Handler.
533  stream = logging.StreamHandler()
534  stream.setFormatter(logging.Formatter(fmt="%(name)s %(levelname)s (fallback): %(message)s"))
535  stream.handle(record)
536  return
537 
538  logger = Log.getLogger(record.name)
539  # Use standard formatting class to format message part of the record
540  message = self.formatter.format(record)
541 
542  logger.logMsg(LevelTranslator.logging2lsstLog(record.levelno),
543  record.filename, record.funcName,
544  record.lineno, message)
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ handle()

def lsst.log.log.logContinued.LogHandler.handle (   self,
  record 
)

Definition at line 505 of file logContinued.py.

505  def handle(self, record):
506  logger = Log.getLogger(record.name)
507  if logger.isEnabledFor(LevelTranslator.logging2lsstLog(record.levelno)):
508  logging.Handler.handle(self, record)
509 

Member Data Documentation

◆ formatter

lsst.log.log.logContinued.LogHandler.formatter

Definition at line 503 of file logContinued.py.


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