You are here

private function JsonLog::loadDefaultSettings in JSONlog 8

Same name and namespace in other branches
  1. 8.2 src/Logger/JsonLog.php \Drupal\jsonlog\Logger\JsonLog::loadDefaultSettings()
  2. 3.x src/Logger/JsonLog.php \Drupal\jsonlog\Logger\JsonLog::loadDefaultSettings()

Fetch all settings of this module.

Always try a server environment var before Drupal configuration var.

1 call to JsonLog::loadDefaultSettings()
JsonLog::__construct in src/Logger/JsonLog.php
JsonLog constructor.

File

src/Logger/JsonLog.php, line 189

Class

JsonLog
Redirects logging messages to jsonlog.

Namespace

Drupal\jsonlog\Logger

Code

private function loadDefaultSettings() {

  // Threshold
  if (!($this->threshold = getenv('drupal_jsonlog_severity_threshold'))) {
    $this->threshold = $this->config
      ->get('jsonlog_severity_threshold');
  }

  // Site ID
  if (!($this->site_id = getenv('drupal_jsonlog_siteid'))) {
    if (!($this->site_id = $this->config
      ->get('jsonlog_siteid'))) {
      $this->moduleHandler
        ->loadInclude('jsonlog', 'inc');
      $this->site_id = jsonlog_default_site_id();
    }
  }

  // Canonical site identifier
  if (!($this->canonical = getenv('drupal_jsonlog_canonical'))) {
    $this->canonical = $this->config
      ->get('jsonlog_canonical');
  }

  // Dir
  if (!($this->dir = getenv('drupal_jsonlog_dir'))) {
    if (!($this->dir = $this->config
      ->get('jsonlog_dir'))) {
      $this->moduleHandler
        ->loadInclude('jsonlog', 'inc');
      if (!($this->dir = jsonlog_default_dir())) {
        error_log('Drupal jsonlog, site ID[' . $this->dir . '], failed to establish server\'s default log dir.');
      }
    }
  }

  // File
  if (!($file_time = getenv('drupal_jsonlog_file_time'))) {
    $file_time = $this->config
      ->get('jsonlog_file_time');
  }
  $this->file = $this
    ->getFileName($file_time);

  // Truncation
  if (($this->truncate = getenv('drupal_jsonlog_truncate')) === FALSE) {
    $this->truncate = $this->config
      ->get('jsonlog_truncate');
  }

  // Tags
  $this->tags_server = ($tags = getenv('drupal_jsonlog_tags')) !== FALSE ? $tags : '';
  $this->tags_site = $this->config
    ->get('jsonlog_tags');
}