-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathDebugLogging.php
73 lines (63 loc) · 1.82 KB
/
DebugLogging.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\MagentoCloud\Config\Validator\Deploy;
use Magento\MagentoCloud\App\Error;
use Magento\MagentoCloud\Config\Magento\SystemInterface;
use Magento\MagentoCloud\Config\ValidatorInterface;
use Magento\MagentoCloud\Config\Environment;
use Magento\MagentoCloud\Config\Validator\ResultInterface;
use Magento\MagentoCloud\Config\Validator\ResultFactory;
/**
* Validate that debug logging is disabled in Magento.
*/
class DebugLogging implements ValidatorInterface
{
const CONFIG_PATH = 'dev/debug/debug_logging';
/**
* @var SystemInterface
*/
private $config;
/**
* @var Environment
*/
private $environment;
/**
* @var ResultFactory
*/
private $resultFactory;
/**
* @param SystemInterface $config
* @param Environment $environment
* @param ResultFactory $resultFactory
*/
public function __construct(
SystemInterface $config,
Environment $environment,
ResultFactory $resultFactory
) {
$this->config = $config;
$this->environment = $environment;
$this->resultFactory = $resultFactory;
}
/**
* {@inheritdoc}
*/
public function validate(): ResultInterface
{
if (!$this->environment->isMasterBranch()) {
return $this->resultFactory->success();
}
if (!$this->config->get(self::CONFIG_PATH)) {
return $this->resultFactory->success();
}
return $this->resultFactory->error(
'Debug logging is enabled in Magento',
'To save space in Magento Cloud, disable debug logging for your production environments.',
Error::WARN_DEBUG_LOG_ENABLED
);
}
}