source: CMIP6dreqbuild/trunk/src/framework/ingest/utils.py @ 713

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/ingest/utils.py@713
Revision 713, 817 bytes checked in by mjuckes, 5 years ago (diff)

New ingestion pathway

Line 
1import logging, os
2import time
3
4class dreqLog(object):
5  def __init__(self, dir='.'):
6    self.tstring2 = '%4.4i%2.2i%2.2i' % time.gmtime()[0:3]
7    self.logdir = dir
8    if not os.path.isdir( dir ):
9      os.mkdir(dir )
10      print ( 'dreqLog: making a new directory fr log files: %s' % dir )
11
12  def getLog(self,name,dir=None):
13    if dir == None:
14      dir = self.logdir
15    testLogFile = '%s/dreq_%s_%s.txt' % (dir,name,self.tstring2)
16    log = logging.getLogger(testLogFile)
17    fileFormatter = logging.Formatter('%(message)s')
18    if os.path.isfile( testLogFile ):
19      os.unlink( testLogFile )
20    self.fHdlr = logging.FileHandler(testLogFile)
21    self.fHdlr.setFormatter(fileFormatter)
22    log.addHandler(self.fHdlr)
23    log.setLevel(logging.INFO)
24    return log
25
26  def shutdown(self):
27    logging.shutdown()
Note: See TracBrowser for help on using the repository browser.