LSSTApplications  18.1.0
LSSTDataManagementBasePackage
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.

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 307 of file logContinued.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 322 of file logContinued.py.

322  def __init__(self, level=logging.NOTSET):
323  logging.Handler.__init__(self, level=level)
324  # Format as a simple message because lsst.log will format the
325  # message a second time.
326  self.formatter = logging.Formatter(fmt="%(message)s")
327 
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ emit()

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

Definition at line 333 of file logContinued.py.

333  def emit(self, record):
334  if Log.UsePythonLogging:
335  # Do not forward this message to lsst.log since this may cause
336  # a logging loop.
337 
338  # Work out whether any other handler is going to be invoked
339  # for this logger.
340  pylgr = logging.getLogger(record.name)
341 
342  # If another handler is registered that is not LogHandler
343  # we ignore this request
344  if any(not isinstance(h, self.__class__) for h in pylgr.handlers):
345  return
346 
347  # If the parent has handlers and propagation is enabled
348  # we punt as well (and if a LogHandler is involved then we will
349  # ask the same question when we get to it).
350  if pylgr.parent and pylgr.parent.hasHandlers() and pylgr.propagate:
351  return
352 
353  # Force this message to appear somewhere.
354  # If something else should happen then the caller should add a
355  # second Handler.
356  stream = logging.StreamHandler()
357  stream.setFormatter(logging.Formatter(fmt="%(name)s %(levelname)s (fallback): %(message)s"))
358  stream.handle(record)
359  return
360 
361  logger = Log.getLogger(record.name)
362  # Use standard formatting class to format message part of the record
363  message = self.formatter.format(record)
364 
365  logger.logMsg(LevelTranslator.logging2lsstLog(record.levelno),
366  record.filename, record.funcName,
367  record.lineno, message)
368 
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:168

◆ handle()

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

Definition at line 328 of file logContinued.py.

328  def handle(self, record):
329  logger = Log.getLogger(record.name)
330  if logger.isEnabledFor(LevelTranslator.logging2lsstLog(record.levelno)):
331  logging.Handler.handle(self, record)
332 

Member Data Documentation

◆ formatter

lsst.log.log.logContinued.LogHandler.formatter

Definition at line 326 of file logContinued.py.


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