diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-22 06:17:24 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-22 06:17:24 +0100 |
commit | f6d3a7c84ebe6d3e6980883828dc4e315176b142 (patch) | |
tree | 9cfb959a60c7b6f4ae0804cab6e59f70519ac52b /save_carefully.py | |
parent | 7769a35f076211ec13a2b798fd8c84569e619984 (diff) | |
download | troggle-f6d3a7c84ebe6d3e6980883828dc4e315176b142.tar.gz troggle-f6d3a7c84ebe6d3e6980883828dc4e315176b142.tar.bz2 troggle-f6d3a7c84ebe6d3e6980883828dc4e315176b142.zip |
[svn] switched from dodgy manually writing to logfile to using python's logging module, which seems great
Diffstat (limited to 'save_carefully.py')
-rw-r--r-- | save_carefully.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/save_carefully.py b/save_carefully.py index f72b4fa..ee7c0cc 100644 --- a/save_carefully.py +++ b/save_carefully.py @@ -1,4 +1,4 @@ -from settings import LOGFILE
+import logging
def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
"""Looks up instance using lookupAttribs and carries out the following:
@@ -18,14 +18,12 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}): setattr(instance, k, v)
instance.save()
- if LOGFILE:
- if created:
- LOGFILE.write(unicode(instance)+u' was just added to the database for the first time. \n')
-
- if not created and instance.new_since_parsing:
- LOGFILE.write(unicode(instance)+" has been modified using Troggle, so the current script left it as is. \n")
+ if created:
+ logging.info(unicode(instance)+u' was just added to the database for the first time. \n')
+
+ if not created and instance.new_since_parsing:
+ logging.info(unicode(instance)+" has been modified using Troggle, so the current script left it as is. \n")
- if not created and not instance.new_since_parsing:
- LOGFILE.write(unicode(instance)+" existed in the database unchanged since last parse. It was overwritten by the current script. \n")
- LOGFILE.flush()
+ if not created and not instance.new_since_parsing:
+ logging.info(unicode(instance)+" existed in the database unchanged since last parse. It was overwritten by the current script. \n")
return (instance, created)
\ No newline at end of file |