summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordencheva <dencheva@stsci.edu>2011-06-02 10:08:53 -0400
committerdencheva <dencheva@stsci.edu>2011-06-02 10:08:53 -0400
commit5083538477943bc59bb6c779a8d2170868205c0a (patch)
tree5e593a744495452c7f3306cf140fd991e8bd8742
parent1bea0d0bb9a21ec64d62216ae8bb084d7bb158ff (diff)
downloadstwcs_hcf-5083538477943bc59bb6c779a8d2170868205c0a.tar.gz
Initially the log file was defined at the top level. Moved it to updatewcs to avoid creating an empty file when logging is not requested.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@12996 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--lib/__init__.py10
-rw-r--r--updatewcs/__init__.py6
2 files changed, 6 insertions, 10 deletions
diff --git a/lib/__init__.py b/lib/__init__.py
index bbed8ae..e2380a8 100644
--- a/lib/__init__.py
+++ b/lib/__init__.py
@@ -15,16 +15,6 @@ import distortion
import pywcs
from pytools import fileutil
-import logging
-log_filename = 'stwcs.log'
-logging.basicConfig(filename=log_filename, level=logging.DEBUG, filemode='w')
-formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
-logger = logging.getLogger('STWCS')
-logger.setLevel(logging.DEBUG)
-fh = logging.FileHandler(log_filename)
-fh.setLevel(logging.DEBUG)
-fh.setFormatter(formatter)
-logger.addHandler(fh)
__docformat__ = 'restructuredtext'
DEGTORAD = fileutil.DEGTORAD
diff --git a/updatewcs/__init__.py b/updatewcs/__init__.py
index c98e67f..ab852d0 100644
--- a/updatewcs/__init__.py
+++ b/updatewcs/__init__.py
@@ -77,6 +77,12 @@ def updatewcs(input, vacorr=True, tddcorr=True, npolcorr=True, d2imcorr=True,
if verbose == False:
logger.setLevel(100)
else:
+ formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+ log_filename = 'stwcs.log'
+ fh = logging.FileHandler(log_filename, mode='w')
+ fh.setLevel(logging.DEBUG)
+ fh.setFormatter(formatter)
+ logger.addHandler(fh)
logger.setLevel(verbose)
args = "vacorr=%s, tddcorr=%s, npolcorr=%s, d2imcorr=%s, checkfiles=%s, \
wcskey=%s, wcsname=%s, clobber=%s" % (str(vacorr), str(tddcorr), str(npolcorr),