You are here

function jsonlog_default_site_id in JSONlog 3.x

Same name and namespace in other branches
  1. 8.2 jsonlog.inc \jsonlog_default_site_id()
  2. 8 jsonlog.inc \jsonlog_default_site_id()
  3. 7.2 jsonlog.inc \jsonlog_default_site_id()
  4. 7 jsonlog.inc \jsonlog_default_site_id()

Establish default site ID.

Server's hostname + __ + (default) database name. If default database also has a prefix: + __ + database prefix.

Return value

string

2 calls to jsonlog_default_site_id()
JsonLog::loadDefaultSettings in src/Logger/JsonLog.php
Fetch all settings of this module.
_jsonlog_form_system_logging_settings_alter in ./jsonlog.inc
Adds this module's setting fields to the system logging settings form.

File

./jsonlog.inc, line 408
JSONlog module helper functions.

Code

function jsonlog_default_site_id() {
  if ($site_id = getenv('drupal_jsonlog_siteid')) {
    return $site_id;
  }
  $db_info = Database::getConnectionInfo();

  // Server's hostname + database name + database prefix (if any).
  $site_id = strtolower(preg_replace('/[^\\w\\d\\.\\-_]/', '-', gethostname())) . '__' . $db_info['default']['database'] . ($db_info['default']['prefix'] && !empty($db_info['default']['prefix']['default']) ? '__' . $db_info['default']['prefix']['default'] : '');
  unset($db_info);

  // Clear ref.
  return $site_id;
}