IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:00:22 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110710/ippToPsps/jython
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/ippToPsps/jython

    • Property svn:ignore set to
      *.class
  • branches/eam_branches/ipp-20110710/ippToPsps/jython/pslogger.py

    r31843 r32337  
    11import logging.config
    2 
     2import datetime
     3import os
     4import sys
    35
    46class PSLogger(logging.getLoggerClass()):
     7
     8   '''
     9   Sets up logging using values from the ippToPsps config file
     10   '''
     11   def setup(self, doc, name, stdout=1, sendToFile=0):
     12
     13       formatter = logging.Formatter('%(asctime)s | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S')
     14       self.setLevel(logging.INFO)
     15
     16       if sendToFile:
     17           PATH = doc.find("localOutPath").text + "/log"
     18           if not os.path.exists(PATH): os.makedirs(PATH)
     19           DVOLABEL = doc.find("dvo/gpc1Label").text
     20           FULLPATH = PATH + "/" + name + "_" + DVOLABEL + ".log"
     21
     22           # opens file to be appended
     23           hdlr = logging.FileHandler(FULLPATH, "a")
     24           hdlr.setFormatter(formatter)
     25           self.addHandler(hdlr)
     26
     27       if stdout:
     28           stdout = logging.StreamHandler(sys.__stdout__)
     29           #stdout.setFormatter(formatter)
     30           self.addHandler(stdout)
     31
     32       if sendToFile: print "Writing log to: " + FULLPATH
    533
    634   def infoPair(self, first, second):
    735       self.info("%-40s%s" % (first, second))
    836
     37   def errorPair(self, first, second):
     38       self.error("%-40s%s" % (first, second))
     39
     40   def debugPair(self, first, second):
     41       self.debug("%-40s%s" % (first, second))
     42
     43   def infoTitle(self, str):
     44       self.info("")
     45       self.info("%40s" % (str))
     46       self.info("")
     47
     48   def infoBool(self, first, bool):
     49       if bool: str = "yes"
     50       else: str = "no"
     51       self.info("%-40s%s" % (first, str))
     52
     53   def errorBool(self, first, bool):
     54       if bool: str = "yes"
     55       else: str = "no"
     56       self.error("%-40s%s" % (first, str))
     57
    958   def infoSeparator(self):
    1059       self.info("--------------------------------------------------------------------------")
    1160
    12    def infoMiniSeparator(self):
    13        self.info("---------------------------")
    14 
Note: See TracChangeset for help on using the changeset viewer.