[], 'scopes' => [], ]; /** * __construct method * * @param array $config Configuration array */ public function __construct(array $config = []) { $this->setConfig($config); if (!is_array($this->_config['scopes']) && $this->_config['scopes'] !== false) { $this->_config['scopes'] = (array)$this->_config['scopes']; } if (!is_array($this->_config['levels'])) { $this->_config['levels'] = (array)$this->_config['levels']; } if (!empty($this->_config['types']) && empty($this->_config['levels'])) { $this->_config['levels'] = (array)$this->_config['types']; } } /** * Get the levels this logger is interested in. * * @return array */ public function levels() { return $this->_config['levels']; } /** * Get the scopes this logger is interested in. * * @return array|false */ public function scopes() { return $this->_config['scopes']; } /** * Converts to string the provided data so it can be logged. The context * can optionally be used by log engines to interpolate variables * or add additional info to the logged message. * * @param mixed $data The data to be converted to string and logged. * @param array $context Additional logging information for the message. * @return string */ protected function _format($data, array $context = []) { if (is_string($data)) { return $data; } $isObject = is_object($data); if ($isObject && $data instanceof EntityInterface) { return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } if ($isObject && method_exists($data, '__toString')) { return (string)$data; } if ($isObject && $data instanceof JsonSerializable) { return json_encode($data, JSON_UNESCAPED_UNICODE); } return print_r($data, true); } }