Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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())