17use PhpConsole\Connector;
18use PhpConsole\Handler;
44 'classesPartialsTraceIgnore' => array(
'Monolog\\'),
45 'debugTagsKeysInContext' => array(0,
'tag'),
46 'useOwnErrorsHandler' =>
false,
47 'useOwnExceptionsHandler' =>
false,
48 'sourcesBasePath' =>
null,
49 'registerHelper' =>
true,
50 'serverEncoding' =>
null,
51 'headersLimit' =>
null,
53 'enableSslOnlyMode' =>
false,
55 'enableEvalListener' =>
false,
56 'dumperDetectCallbacks' =>
false,
57 'dumperLevelLimit' => 5,
58 'dumperItemsCountLimit' => 100,
59 'dumperItemSizeLimit' => 5000,
60 'dumperDumpSizeLimit' => 500000,
61 'detectDumpTraceAndSource' =>
false,
62 'dataStorage' =>
null,
77 if (!class_exists(
'PhpConsole\Connector')) {
78 throw new Exception(
'PHP Console library not found. See https://github.com/barbushin/php-console#installation');
87 $wrongOptions = array_diff(array_keys(
$options), array_keys($this->options));
89 throw new Exception(
'Unknown options: ' . implode(
', ', $wrongOptions));
92 return array_replace($this->options,
$options);
98 if ($this->options[
'dataStorage']) {
99 Connector::setPostponeStorage($this->options[
'dataStorage']);
104 if ($this->options[
'registerHelper'] && !Helper::isRegistered()) {
108 if ($this->options[
'enabled'] &&
$connector->isActiveClient()) {
109 if ($this->options[
'useOwnErrorsHandler'] || $this->options[
'useOwnExceptionsHandler']) {
110 $handler = Handler::getInstance();
111 $handler->setHandleErrors($this->options[
'useOwnErrorsHandler']);
112 $handler->setHandleExceptions($this->options[
'useOwnExceptionsHandler']);
115 if ($this->options[
'sourcesBasePath']) {
116 $connector->setSourcesBasePath($this->options[
'sourcesBasePath']);
118 if ($this->options[
'serverEncoding']) {
119 $connector->setServerEncoding($this->options[
'serverEncoding']);
121 if ($this->options[
'password']) {
122 $connector->setPassword($this->options[
'password']);
124 if ($this->options[
'enableSslOnlyMode']) {
127 if ($this->options[
'ipMasks']) {
128 $connector->setAllowedIpMasks($this->options[
'ipMasks']);
130 if ($this->options[
'headersLimit']) {
131 $connector->setHeadersLimit($this->options[
'headersLimit']);
133 if ($this->options[
'detectDumpTraceAndSource']) {
134 $connector->getDebugDispatcher()->detectTraceAndSource =
true;
137 $dumper->levelLimit = $this->options[
'dumperLevelLimit'];
138 $dumper->itemsCountLimit = $this->options[
'dumperItemsCountLimit'];
139 $dumper->itemSizeLimit = $this->options[
'dumperItemSizeLimit'];
140 $dumper->dumpSizeLimit = $this->options[
'dumperDumpSizeLimit'];
141 $dumper->detectCallbacks = $this->options[
'dumperDetectCallbacks'];
142 if ($this->options[
'enableEvalListener']) {
162 if ($this->options[
'enabled'] && $this->connector->isActiveClient()) {
163 return parent::handle($record);
175 protected function write(array $record)
179 } elseif (isset($record[
'context'][
'exception']) && $record[
'context'][
'exception'] instanceof Exception) {
189 $message = $record[
'message'];
190 if ($record[
'context']) {
191 $message .=
' ' . json_encode($this->connector->getDumper()->dump(array_filter($record[
'context'])));
193 $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options[
'classesPartialsTraceIgnore']);
198 $this->connector->getErrorsDispatcher()->dispatchException($record[
'context'][
'exception']);
203 $context = $record[
'context'];
205 $this->connector->getErrorsDispatcher()->dispatchError(
206 isset($context[
'code']) ? $context[
'code'] :
null,
207 isset($context[
'message']) ? $context[
'message'] : $record[
'message'],
208 isset($context[
'file']) ? $context[
'file'] :
null,
209 isset($context[
'line']) ? $context[
'line'] :
null,
210 $this->options[
'classesPartialsTraceIgnore']
217 if (!empty($record[
'context'])) {
218 $context = & $record[
'context'];
219 foreach ($this->options[
'debugTagsKeysInContext'] as $key) {
220 if (!empty($context[$key])) {
221 $tags = $context[$key];
223 array_shift($context);
225 unset($context[$key]);
232 return $tags ?: strtolower($record[
'level_name']);
An exception for terminatinating execution or to throw for unit testing.
Base Handler class providing the Handler structure.
Monolog handler for Google Chrome extension "PHP Console".
getDefaultFormatter()
Gets the default formatter.FormatterInterface
handleErrorRecord(array $record)
getRecordTags(array &$record)
write(array $record)
Writes the record down to the log of the implementing handler.
__construct(array $options=array(), Connector $connector=null, $level=Logger::DEBUG, $bubble=true)
initOptions(array $options)
initConnector(Connector $connector=null)
handleExceptionRecord(array $record)
handle(array $record)
{{Handles a record.All records may be passed to this method, and the handler should discard those tha...
handleDebugRecord(array $record)
const DEBUG
Detailed debug information.
const NOTICE
Uncommon events.