function _drush_usage_log

8.0.x usage.drush.inc _drush_usage_log($command, $file)
6.x usage.drush.inc _drush_usage_log($command, $file)
7.x usage.drush.inc _drush_usage_log($command, $file)
5.x usage.drush.inc _drush_usage_log($command, $file)
1 call to _drush_usage_log()

File

commands/core/usage.drush.inc, line 90
Send scrubbed usage data to drush. Omits arguments and option values in order to assure that no sensitive data is shared. See http://drupal.org/node/1246738.

Code

function _drush_usage_log($command, $file) {
  _drush_merge_engine_data($command);

  // Start out with just the options in the current command record.
  $options = _drush_get_command_options($command);
  // If 'allow-additional-options' contains a list of command names,
  // then union together all of the options from all of the commands.
  if (is_array($command['allow-additional-options'])) {
    $implemented = drush_get_commands();
    foreach ($command['allow-additional-options'] as $subcommand_name) {
      if (array_key_exists($subcommand_name, $implemented)) {
        $options = array_merge($options, _drush_get_command_options($implemented[$subcommand_name]));
      }
    }
  }

  $used = drush_get_merged_options();
  $command_specific = array_intersect(array_keys($used), array_keys($options));
  $record = array(
    'date' => $_SERVER['REQUEST_TIME'],
    'cmd' => $command['command'],
    'opt' => $command_specific,
    'major' => DRUSH_MAJOR_VERSION,
    'minor' => DRUSH_MINOR_VERSION,
    'os' => php_uname('s'),
    'host' => md5(php_uname('n') . get_current_user()),
  );
  $prequel = (file_exists($file)) ? ",\n" : "";
  if (file_put_contents($file, $prequel . json_encode($record), FILE_APPEND)) {
    drush_log(dt('Logged command and option names to local cache.'), 'debug');
  }
  else {
    drush_log(dt('Failed to log command and option names to local cache.'), 'debug');
  }
}