jenkins-bot has submitted this change and it was merged.

Change subject: Logging: Add logging to JsonDict.js
......................................................................


Logging: Add logging to JsonDict.js

Change-Id: Ifd5f95039483d2be2349c8b95b8e34a8b783c29b
---
M dictionary/jsondict/JsonDict.js
1 file changed, 16 insertions(+), 6 deletions(-)

Approvals:
  KartikMistry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/dictionary/jsondict/JsonDict.js b/dictionary/jsondict/JsonDict.js
index 7f0ae9d..24f37b3 100644
--- a/dictionary/jsondict/JsonDict.js
+++ b/dictionary/jsondict/JsonDict.js
@@ -1,6 +1,7 @@
 var dictRegistry = require( __dirname + '/JsonDictRegistry.json' ),
        fs = require( 'fs' ),
-       Q = require( 'q' );
+       Q = require( 'q' ),
+       logger = require( __dirname + '/../../utils/Logger.js' );
 
 /**
  * Find bilingual dictionaries for the language pair
@@ -46,6 +47,7 @@
 
        dictionaries = findDictionaries( sourceLang, targetLang );
        if ( dictionaries === null ) {
+               logger.error( 'JSON dictionary not found for %s-%s', 
sourceLang, targetLang );
                deferred.resolve( [] );
                return deferred.promise;
        }
@@ -61,19 +63,27 @@
                var results, result, i, len,
                        translations = [];
                if ( err ) {
-                       deferred.reject( 'Error: ' + err );
+                       logger.error( 'Dictionary file \'%s\' could not be 
read', file );
+                       deferred.reject( '' + err );
                        return;
                }
                results = JSON.parse( data )[source] || [];
                for ( i = 0, len = results.length; i < len; i++ ) {
                        result = results[i];
                        translations.push( {
-                               'phrase': result[0],
-                               'info': result[1],
-                               'sources': [dictionaryId]
+                               phrase: result[0],
+                               info: result[1],
+                               sources: [ dictionaryId ]
                        } );
                }
-               deferred.resolve( { 'source': source, 'translations': 
translations } );
+
+               if ( translations.length < 1 ) {
+                       logger.debug( 'No dictionary entries found' );
+               } else {
+                       logger.debug( 'Dictionary entries found' );
+               }
+
+               deferred.resolve( { source: source, translations: translations 
} );
        } );
        return deferred.promise;
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/159362
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd5f95039483d2be2349c8b95b8e34a8b783c29b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Jsahleen <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to