support for log to a variable
diff --git a/xos/tosca/destroy.py b/xos/tosca/destroy.py
index 968e450..e5f5c37 100644
--- a/xos/tosca/destroy.py
+++ b/xos/tosca/destroy.py
@@ -26,7 +26,7 @@
 
     u = User.objects.get(email=username)
 
-    xt = XOSTosca(file(template_name).read(), parent_dir=currentdir)
+    xt = XOSTosca(file(template_name).read(), parent_dir=currentdir, log_to_console=True)
     xt.destroy(u)
 
 if __name__=="__main__":
diff --git a/xos/tosca/engine.py b/xos/tosca/engine.py
index a0d917d..b70bd94 100644
--- a/xos/tosca/engine.py
+++ b/xos/tosca/engine.py
@@ -2,6 +2,8 @@
 import pdb
 import sys
 import tempfile
+import traceback
+
 sys.path.append("/opt/tosca")
 from translator.toscalib.tosca_template import ToscaTemplate
 
@@ -12,21 +14,29 @@
 import resources
 
 class XOSTosca(object):
-    def __init__(self, tosca_yaml, parent_dir=None):
+    def __init__(self, tosca_yaml, parent_dir=None, log_to_console = False):
         # TOSCA will look for imports using a relative path from where the
         # template file is located, so we have to put the template file
         # in a specific place.
         if not parent_dir:
             parent_dir = os.getcwd()
 
+        tmp_pathname = None
         try:
             (tmp_handle, tmp_pathname) = tempfile.mkstemp(dir=parent_dir)
             os.write(tmp_handle, tosca_yaml)
             os.close(tmp_handle)
 
             self.template = ToscaTemplate(tmp_pathname)
+        except:
+            traceback.print_exc()
+            raise
         finally:
-            os.remove(tmp_pathname)
+            if tmp_pathname:
+                os.remove(tmp_pathname)
+
+        self.log_to_console = log_to_console
+        self.log_msgs = []
 
         self.compute_dependencies()
 
@@ -39,6 +49,11 @@
 
         #pdb.set_trace()
 
+    def log(self, msg):
+        if self.log_to_console:
+            print msg
+        self.log_msgs.append(msg)
+
     def compute_dependencies(self):
         nodetemplates_by_name = {}
         for nodetemplate in self.template.nodetemplates:
@@ -136,7 +151,6 @@
                     models.append( (obj, model) )
         models.reverse()
         for (resource,model) in models:
-            print "destroying", model
             resource.delete(model)
 
     def name_to_xos_class(self, user, name):
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 0fc1c78..e848ab5 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -108,9 +108,10 @@
         pass
 
     def delete(self, obj):
+        self.info("destroying object %s" % str(obj))
         self.pre_delete(obj)
         obj.delete(purge=True)   # XXX TODO: turn off purge before production
 
     def info(self, s):
-        print s
+        self.engine.log(s)
 
diff --git a/xos/tosca/run.py b/xos/tosca/run.py
index 45a87ea..87fb480 100644
--- a/xos/tosca/run.py
+++ b/xos/tosca/run.py
@@ -26,7 +26,7 @@
 
     u = User.objects.get(email=username)
 
-    xt = XOSTosca(file(template_name).read(), parent_dir=currentdir)
+    xt = XOSTosca(file(template_name).read(), parent_dir=currentdir, log_to_console=True)
     xt.execute(u)
 
 if __name__=="__main__":