|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / amasty / base / Debug / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/amasty/base/Debug/Log.php |
Size | 3.05 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 16-Aug-2022 09:35 |
Last accessed | 23-Aug-2025 16:29 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package Magento 2 Base Package
*/
namespace Amasty\Base\Debug;
/**
* For Remote Debug
* Output is going to file amasty_debug.log
* @codeCoverageIgnore
* @codingStandardsIgnoreFile
*/
class Log
{
/**
* @var \Magento\Framework\Logger\Monolog
*/
private static $loggerInstance;
/**
* @var string
*/
private static $fileToLog = 'amasty_debug.log';
public static function execute()
{
if (VarDump::isAllowed()) {
foreach (func_get_args() as $var) {
self::logToFile(
System\LogBeautifier::getInstance()->beautify(
VarDump::dump($var)
)
);
}
}
}
/**
* @param int $level
*/
public static function setObjectDepthLevel($level)
{
VarDump::setObjectDepthLevel((int)$level);
}
/**
* @param int $level
*/
public static function setArrayDepthLevel($level)
{
VarDump::setArrayDepthLevel((int)$level);
}
/**
* @param string $filename
*/
public static function setLogFile($filename)
{
if (preg_match('/^[a-z_]+\.log$/i', $filename)) {
self::$fileToLog = $filename;
}
}
/**
* Log debug_backtrace
*/
public static function backtrace()
{
if (VarDump::isAllowed()) {
$backtrace = debug_backtrace();
array_shift($backtrace);
foreach ($backtrace as $key => $route) {
$backtrace[$key] = [
'action' => $route['class'] . $route['type'] . $route['function'] . '()',
'file' => $route['file'] . ':' . $route['line']
];
}
self::logToFile(System\LogBeautifier::getInstance()->beautify(VarDump::dump($backtrace)));
}
}
/**
* @param string $var
*/
private static function logToFile($var)
{
self::getLogger()->addRecord(200, $var);
}
/**
* @return \Magento\Framework\Logger\Monolog
*/
private static function getLogger()
{
if (!self::$loggerInstance) {
self::configureInstance();
}
return self::$loggerInstance;
}
private static function configureInstance()
{
$logDir = \Magento\Framework\App\ObjectManager::getInstance()
->get('\Magento\Framework\Filesystem\DirectoryList')
->getPath('log');
$handler = new \Monolog\Handler\RotatingFileHandler($logDir . DIRECTORY_SEPARATOR . self::$fileToLog, 2);
$output = "\n----------------------------------------------------------------------------\n%datetime%\n
%message%
----------------------------------------------------------------------------\n\n";
$formatter = new System\AmastyFormatter($output);
$handler->setFormatter($formatter);
self::$loggerInstance = new \Magento\Framework\Logger\Monolog('amasty_logger', [$handler]);
}
}
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package Magento 2 Base Package
*/
namespace Amasty\Base\Debug;
/**
* For Remote Debug
* Output is going to file amasty_debug.log
* @codeCoverageIgnore
* @codingStandardsIgnoreFile
*/
class Log
{
/**
* @var \Magento\Framework\Logger\Monolog
*/
private static $loggerInstance;
/**
* @var string
*/
private static $fileToLog = 'amasty_debug.log';
public static function execute()
{
if (VarDump::isAllowed()) {
foreach (func_get_args() as $var) {
self::logToFile(
System\LogBeautifier::getInstance()->beautify(
VarDump::dump($var)
)
);
}
}
}
/**
* @param int $level
*/
public static function setObjectDepthLevel($level)
{
VarDump::setObjectDepthLevel((int)$level);
}
/**
* @param int $level
*/
public static function setArrayDepthLevel($level)
{
VarDump::setArrayDepthLevel((int)$level);
}
/**
* @param string $filename
*/
public static function setLogFile($filename)
{
if (preg_match('/^[a-z_]+\.log$/i', $filename)) {
self::$fileToLog = $filename;
}
}
/**
* Log debug_backtrace
*/
public static function backtrace()
{
if (VarDump::isAllowed()) {
$backtrace = debug_backtrace();
array_shift($backtrace);
foreach ($backtrace as $key => $route) {
$backtrace[$key] = [
'action' => $route['class'] . $route['type'] . $route['function'] . '()',
'file' => $route['file'] . ':' . $route['line']
];
}
self::logToFile(System\LogBeautifier::getInstance()->beautify(VarDump::dump($backtrace)));
}
}
/**
* @param string $var
*/
private static function logToFile($var)
{
self::getLogger()->addRecord(200, $var);
}
/**
* @return \Magento\Framework\Logger\Monolog
*/
private static function getLogger()
{
if (!self::$loggerInstance) {
self::configureInstance();
}
return self::$loggerInstance;
}
private static function configureInstance()
{
$logDir = \Magento\Framework\App\ObjectManager::getInstance()
->get('\Magento\Framework\Filesystem\DirectoryList')
->getPath('log');
$handler = new \Monolog\Handler\RotatingFileHandler($logDir . DIRECTORY_SEPARATOR . self::$fileToLog, 2);
$output = "\n----------------------------------------------------------------------------\n%datetime%\n
%message%
----------------------------------------------------------------------------\n\n";
$formatter = new System\AmastyFormatter($output);
$handler->setFormatter($formatter);
self::$loggerInstance = new \Magento\Framework\Logger\Monolog('amasty_logger', [$handler]);
}
}