Coverage for python/lsst/ctrl/pool/log.py: 38%
19 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-23 10:40 +0000
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-23 10:40 +0000
1import logging
2import os
3import copyreg
4import lsst.log as lsstLog
5from lsst.utils import getPackageDir
8def pickleLog(log):
9 """Pickle a log
11 Assumes that we're always just using the lsst.log default.
12 """
13 return lsstLog.Log, tuple()
16copyreg.pickle(lsstLog.Log, pickleLog)
19def 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())
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())