[data import log] log on the source so we properly have source name information
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Nov 2011 14:34:03 +0100
changeset 8068 72210779ff6d
parent 8067 3841d8793efb
child 8069 4341fb713b14
[data import log] log on the source so we properly have source name information
entities/sources.py
server/sources/datafeed.py
--- a/entities/sources.py	Wed Nov 09 15:06:03 2011 +0100
+++ b/entities/sources.py	Wed Nov 09 14:34:03 2011 +0100
@@ -137,10 +137,11 @@
 
 class CWDataImport(AnyEntity):
     __regid__ = 'CWDataImport'
+    repo_source = _logs = None # please pylint
 
-    def __init__(self, *args, **kwargs):
-        super(CWDataImport, self).__init__(*args, **kwargs)
+    def init(self):
         self._logs = []
+        self.repo_source = self.cwsource.repo_source
 
     def dc_title(self):
         return '%s [%s]' % (self.printable_value('start_timestamp'),
@@ -152,25 +153,25 @@
 
     def record_debug(self, msg, path=None, line=None):
         self._log(logging.DEBUG, msg, path, line)
-        self.debug(msg)
+        self.repo_source.debug(msg)
 
     def record_info(self, msg, path=None, line=None):
         self._log(logging.INFO, msg, path, line)
-        self.info(msg)
+        self.repo_source.info(msg)
 
     def record_warning(self, msg, path=None, line=None):
         self._log(logging.WARNING, msg, path, line)
-        self.warning(msg)
+        self.repo_source.warning(msg)
 
     def record_error(self, msg, path=None, line=None):
         self._status = u'failed'
         self._log(logging.ERROR, msg, path, line)
-        self.error(msg)
+        self.repo_source.error(msg)
 
     def record_fatal(self, msg, path=None, line=None):
         self._status = u'failed'
         self._log(logging.FATAL, msg, path, line)
-        self.fatal(msg)
+        self.repo_source.fatal(msg)
 
     def _log(self, severity, msg, path=None, line=None):
         encodedmsg =  u'%s\t%s\t%s\t%s<br/>' % (severity, path or u'',
--- a/server/sources/datafeed.py	Wed Nov 09 15:06:03 2011 +0100
+++ b/server/sources/datafeed.py	Wed Nov 09 14:34:03 2011 +0100
@@ -272,6 +272,7 @@
         dataimport = session.create_entity('CWDataImport', cw_import_of=self,
                                            start_timestamp=datetime.utcnow(),
                                            **kwargs)
+        dataimport.init()
         return dataimport
 
 class DataFeedParser(AppObject):