From 0d278e0abff5ede4615be8c8cdad2461e33495dd Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Thu, 10 Mar 2016 00:12:34 -0500 Subject: [PATCH] Drupal: Couple translation import logging to debug flag https://dev.gridrepublic.org/browse/DBOINCP-235 --- .../boinctranslate/boinctranslate.module | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module index 148fdd02d2..730bcfdc70 100644 --- a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module +++ b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module @@ -714,6 +714,7 @@ function boinctranslate_refresh_translations() { $languages = locale_language_list(); $translation_resources = array(); $operations = array(); + $debug_mode = variable_get('boinc_debug_mode', 0); $boinc_name = variable_get( 'boinc_translate_transifex_standard_name', '' @@ -786,7 +787,7 @@ function boinctranslate_refresh_translations() { $operations[] = array( 'boinctranslate_refresh_translations_op', array( - $project, $resource, $langcode, $language, $translation['textgroups'] + $project, $resource, $langcode, $language, $translation['textgroups'], $debug_mode ), ); } @@ -796,7 +797,7 @@ function boinctranslate_refresh_translations() { $operations[] = array( 'boinctranslate_refresh_translations_op', array( - NULL, $op[1][0], $langcode, $language, array('default') + NULL, $op[1][0], $langcode, $language, array('default'), $debug_mode ), ); } @@ -820,15 +821,17 @@ function boinctranslate_refresh_translations() { /** * Batch operation for importing translations */ -function boinctranslate_refresh_translations_op($project, $resource, $langcode, $language, $textgroups, &$context) { +function boinctranslate_refresh_translations_op($project, $resource, $langcode, $language, $textgroups, $debug_mode, &$context) { require_once(getcwd() . '/includes/locale.inc'); - watchdog( - 'boinctranslate', - 'Checking for @language updates in @project:@resource', - array('@language' => $language, '@project' => $project, '@resource' => $resource), - WATCHDOG_INFO - ); + if ($debug_mode) { + watchdog( + 'boinctranslate', + 'Checking for @language updates in @project:@resource', + array('@language' => $language, '@project' => $project, '@resource' => $resource), + WATCHDOG_INFO + ); + } if ($project) { // Import the configured resources @@ -898,12 +901,15 @@ function boinctranslate_refresh_translations_op($project, $resource, $langcode, // Store some result for post-processing in the finished callback. $context['results']['success'][] = "{$langcode}:{$textgroup}"; $message = "Imported {$language} translations in {$project}:{$resource} ({$results['new']} added, {$results['updated']} refreshed, {$results['deleted']} removed)"; - watchdog( - 'boinctranslate', - $message, - array(), - WATCHDOG_INFO - ); + + if ($debug_mode) { + watchdog( + 'boinctranslate', + $message, + array(), + WATCHDOG_INFO + ); + } } else { $context['results']['failure'][] = "{$langcode}:{$textgroup}";