lsst.ctrl.pool  22.0.1-2-g92698f7+185899cec0
log.py
Go to the documentation of this file.
1 import logging
2 import os
3 import copyreg
4 import lsst.log as lsstLog
5 from lsst.utils import getPackageDir
6 
7 
8 def pickleLog(log):
9  """Pickle a log
10 
11  Assumes that we're always just using the lsst.log default.
12  """
13  return lsstLog.Log, tuple()
14 
15 
16 copyreg.pickle(lsstLog.Log, pickleLog)
17 
18 
19 def jobLog(job):
20  """Add a job-specific log destination"""
21  if job is None or job == "None":
22  return
23  packageDir = getPackageDir("ctrl_pool")
24  # Set the environment variable which names the output file
25  os.environ['JOBNAME'] = job
26  lsstLog.configure(os.path.join(packageDir, "config/log4cxx.properties"))
27  lsstLog.MDC("PID", os.getpid())
28 
29  # Forward python logging to lsst.log
30  lgr = logging.getLogger()
31  lsst_log_level = lsstLog.getDefaultLogger().getEffectiveLevel()
32  lgr.setLevel(lsstLog.LevelTranslator.lsstLog2logging(lsst_log_level))
33  lgr.addHandler(lsstLog.LogHandler())
def pickleLog(log)
Definition: log.py:8
def jobLog(job)
Definition: log.py:19