You are here

public function BufferLogger::__construct in TMGMT Translator Smartling 8.2

Same name and namespace in other branches
  1. 8.4 src/Logger/BufferLogger.php \Drupal\tmgmt_smartling\Logger\BufferLogger::__construct()
  2. 8.3 src/Logger/BufferLogger.php \Drupal\tmgmt_smartling\Logger\BufferLogger::__construct()

BufferLogger constructor.

Parameters

Client $http_client:

LogMessageParserInterface $parser:

ConfigFactoryInterface $config_factory:

RequestStack $request_stack:

array $channels:

int $log_level:

string $host:

int $buffer_limit:

int $time_out:

File

src/Logger/BufferLogger.php, line 111

Class

BufferLogger
Class BufferLogger

Namespace

Drupal\tmgmt_smartling\Logger

Code

public function __construct(Client $http_client, LogMessageParserInterface $parser, ConfigFactoryInterface $config_factory, RequestStack $request_stack, $channels = [
  'tmgmt_smartling',
  'tmgmt_smartling_context_debug',
  'tmgmt_extension_suit',
  'smartling_api',
], $log_level = RfcLogLevel::DEBUG, $host = 'https://api.smartling.com/updates/status', $buffer_limit = 100, $time_out = 5) {
  $this->buffer = [];
  $this->http_client = $http_client;
  $this->channels = $channels;
  $this->parser = $parser;
  $this->config_factory = $config_factory;
  $this->request_stack = $request_stack;
  $this->log_level = $log_level;
  $this->host = $host;
  $this->buffer_limit = $buffer_limit;
  $this->time_out = $time_out;

  // Pick up first available Smartling provider settings.
  $translator_ids = $this->config_factory
    ->listAll('tmgmt.translator');
  foreach ($translator_ids as $id) {
    $config = $this->config_factory
      ->get($id);
    if ($config
      ->get('plugin') === 'smartling') {
      $this->provider_settings = $config
        ->getRawData();
      break;
    }
  }
  drupal_register_shutdown_function([
    $this,
    'flush',
  ]);
}