lsst.ctrl.pool g6ea9deef35+3d88839538
log.py
Go to the documentation of this file.
1import logging
2import os
3import copyreg
4import lsst.log as lsstLog
5from lsst.utils import getPackageDir
6
7
8def 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
16copyreg.pickle(lsstLog.Log, pickleLog)
17
18
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())
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