[ckan-changes] commit/ckanextiati: amercader: Better log messages. Also use a custom log handler, otherwise messages don't get logged

Bitbucket commits-noreply at bitbucket.org
Wed Nov 2 16:52:25 UTC 2011


1 new commit in ckanextiati:


https://bitbucket.org/okfn/ckanextiati/changeset/9b9f1ad1ba54/
changeset:   9b9f1ad1ba54
branch:      resource-archiver
user:        amercader
date:        2011-11-02 17:52:07
summary:     Better log messages. Also use a custom log handler, otherwise messages don't get logged
affected #:  1 file

diff -r e6fd499ac9c36c35867b0cc706bd6136fa729de7 -r 9b9f1ad1ba54734bf4ba726f201c7f49b6ddb005 ckanext/iati/commands.py
--- a/ckanext/iati/commands.py
+++ b/ckanext/iati/commands.py
@@ -12,8 +12,7 @@
 from ckanext.archiver import tasks
 import logging
 
-log = logging.getLogger(__name__)
-
+log = logging.getLogger('iati_archiver')
 
 class Archiver(CkanCommand):
     '''
@@ -65,12 +64,12 @@
             data_formats = tasks.DATA_FORMATS
             data_formats.append('iati-xml')
 
+            log.info('IATI Archiver: starting  %s' % str(t1))
             log.info('Number of datasets to archive: %d' % len(packages))
             updated = 0
             for package_id in packages:
                 package = get_action('package_show_rest')(context,{'id': package_id})
 
-
                 is_activity_package = (package['extras']['filetype'] == 'activity') if 'filetype' in package['extras'] else 'activity'
 
                 log.info('Archiving dataset: %s (%d resources)' % (package.get('name'), len(package.get('resources', []))))
@@ -89,10 +88,10 @@
                             # * But only the first time a file is downloaded!?
                             result = _download_resource(context,resource,data_formats=data_formats)
                         else:
-                            log.error('Invalid resource URL: %s' % str(e))
+                            log.error('Invalid resource URL for dataset %s: %s' % (package['name'],str(e)))
                             continue
-                    except tasks.DownloadError:
-                        log.error('Error downloading resource: %s' % str(e))
+                    except tasks.DownloadError,e:
+                        log.error('Error downloading resource for dataset %s: %s' % (package['name'],str(e)))
                         continue
 
                     if 'zip' in result['headers']['content-type']:
@@ -155,7 +154,7 @@
 
             t2 = datetime.datetime.now()
 
-            log.info('Done. Updated %i packages. Total time: %s' % (updated,str(t2 - t1)))
+            log.info('IATI Archiver: Done. Updated %i packages. Total time: %s' % (updated,str(t2 - t1)))
         else:
             log.error('Command %s not recognized' % (cmd,))

Repository URL: https://bitbucket.org/okfn/ckanextiati/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list