-
Notifications
You must be signed in to change notification settings - Fork 20
Logging improvements #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\CloudComponents\Model; | ||
BarnyShergold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Class to get compressed debug back trace | ||
*/ | ||
class DebugTrace | ||
{ | ||
/** | ||
* List of useless classes | ||
* | ||
* @var string[] | ||
*/ | ||
private $notAllowedClasses = [ | ||
'Symfony\Component\Console\Application', | ||
'Magento\Framework\Console\Cli', | ||
'Symfony\Component\Console\Command\Command', | ||
'Magento\Staging\Model\Event\Manager\Proxy', | ||
'Magento\Staging\Model\Event\Manager', | ||
'Magento\Framework\Event\Invoker\InvokerDefault', | ||
'Magento\CloudComponents\Model\Observer\CacheFlushAll', | ||
'Magento\CloudComponents\Model\Cache\InvalidateLogger', | ||
'Magento\CloudComponents\Model\Cache\InvalidateLogger', | ||
'Magento\CloudComponents\Model\Indexation\Logger', | ||
'Magento\Framework\Cache\Frontend\Decorator\Logger', | ||
'Magento\Framework\Cache\Frontend\Decorator\Bare', | ||
'Magento\Framework\App\Cache\Type\AccessProxy', | ||
'Magento\Framework\Cache\Frontend\Decorator\TagScope', | ||
'Magento\Framework\ObjectManager\ObjectManager', | ||
'Magento\Framework\ObjectManager\Config\Compiled', | ||
'Magento\Framework\ObjectManager\Config\Config', | ||
'Magento\Framework\ObjectManager\Factory\Dynamic\Developer', | ||
'Magento\Framework\ObjectManager\Factory\Dynamic\Production' | ||
]; | ||
|
||
/** | ||
* List of useless functions | ||
* | ||
* @var string[] | ||
*/ | ||
private $notAllowedFunctions = [ | ||
'___callPlugins', | ||
'___callParent', | ||
'Magento\Framework\Interception\{closure}' | ||
]; | ||
|
||
/** | ||
* Returns debug back trace | ||
* | ||
* @return array | ||
*/ | ||
public function getTrace() | ||
{ | ||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
foreach ($trace as $index => $line) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add validation if elements of array
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can I reproduce case when the file key undefined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Such error happening during There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
if (!isset($line['function'], $line['class'], $line['file'])) { | ||
continue; | ||
} | ||
if (in_array($line['function'], $this->notAllowedFunctions) | ||
|| in_array($line['class'], $this->notAllowedClasses) | ||
|| strpos($line['file'], 'Interceptor.php') !== false | ||
) { | ||
unset($trace[$index]); | ||
} | ||
unset($trace[$index]['type']); | ||
} | ||
|
||
if (function_exists('gzcompress')) { | ||
return bin2hex( | ||
gzcompress( | ||
print_r( | ||
$trace, | ||
true | ||
) | ||
) | ||
); | ||
} | ||
return $trace; | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.