Skip to content

Commit 514383b

Browse files
MAGETWO-52767: [Github] Not possible to disable DEBUG logging #4362
1 parent 96ef03b commit 514383b

File tree

2 files changed

+3
-46
lines changed

2 files changed

+3
-46
lines changed

app/code/Magento/Developer/Model/Logger/Handler/Debug.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\Framework\App\State;
1010
use Magento\Framework\Filesystem\DriverInterface;
1111
use Magento\Store\Model\ScopeInterface;
12-
use Magento\Store\Model\StoreManagerInterface;
1312

1413
/**
1514
* Class Debug
@@ -26,42 +25,32 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
2625
*/
2726
private $scopeConfig;
2827

29-
/**
30-
* @var StoreManagerInterface
31-
*/
32-
private $storeManager;
33-
3428
/**
3529
* @param DriverInterface $filesystem
3630
* @param State $state
3731
* @param ScopeConfigInterface $scopeConfig
38-
* @param StoreManagerInterface $storeManager
3932
* @param string $filePath
4033
*/
4134
public function __construct(
4235
DriverInterface $filesystem,
4336
State $state,
4437
ScopeConfigInterface $scopeConfig,
45-
StoreManagerInterface $storeManager,
4638
$filePath = null
4739
) {
4840
parent::__construct($filesystem, $filePath);
4941

5042
$this->state = $state;
5143
$this->scopeConfig = $scopeConfig;
52-
$this->storeManager = $storeManager;
5344
}
5445

5546
/**
5647
* {@inheritdoc}
5748
*/
5849
public function isHandling(array $record)
5950
{
60-
$storeCode = $this->storeManager->getStore()->getCode();
61-
6251
return
6352
parent::isHandling($record)
6453
&& $this->state->getMode() !== State::MODE_PRODUCTION
65-
&& $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, $storeCode);
54+
&& $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE);
6655
}
6756
}

app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
use Magento\Framework\App\State;
1111
use Magento\Framework\Filesystem\DriverInterface;
1212
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13-
use Magento\Store\Api\Data\StoreInterface;
1413
use Magento\Store\Model\ScopeInterface;
15-
use Magento\Store\Model\StoreManagerInterface;
1614
use Monolog\Formatter\FormatterInterface;
1715
use Monolog\Logger;
1816

@@ -41,16 +39,6 @@ class DebugTest extends \PHPUnit_Framework_TestCase
4139
*/
4240
private $scopeConfigMock;
4341

44-
/**
45-
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
46-
*/
47-
private $storeManagerMock;
48-
49-
/**
50-
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
51-
*/
52-
private $storeMock;
53-
5442
/**
5543
* @var FormatterInterface|\PHPUnit_Framework_MockObject_MockObject
5644
*/
@@ -65,16 +53,9 @@ protected function setUp()
6553
->getMock();
6654
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
6755
->getMockForAbstractClass();
68-
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
69-
->getMockForAbstractClass();
70-
$this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
71-
->getMockForAbstractClass();
7256
$this->formatterMock = $this->getMockBuilder(FormatterInterface::class)
7357
->getMockForAbstractClass();
7458

75-
$this->storeManagerMock->expects($this->any())
76-
->method('getStore')
77-
->willReturn($this->storeMock);
7859
$this->formatterMock->expects($this->any())
7960
->method('format')
8061
->willReturn(null);
@@ -83,32 +64,25 @@ protected function setUp()
8364
'filesystem' => $this->filesystemMock,
8465
'state' => $this->stateMock,
8566
'scopeConfig' => $this->scopeConfigMock,
86-
'storeManager' => $this->storeManagerMock
8767
]);
8868
$this->model->setFormatter($this->formatterMock);
8969
}
9070

9171
public function testHandle()
9272
{
93-
$this->storeMock->expects($this->once())
94-
->method('getCode')
95-
->willReturn('test_code');
9673
$this->stateMock->expects($this->once())
9774
->method('getMode')
9875
->willReturn(State::MODE_DEVELOPER);
9976
$this->scopeConfigMock->expects($this->once())
10077
->method('getValue')
101-
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, 'test_code')
78+
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null)
10279
->willReturn(true);
10380

10481
$this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]);
10582
}
10683

10784
public function testHandleDisabledByProduction()
10885
{
109-
$this->storeMock->expects($this->once())
110-
->method('getCode')
111-
->willReturn('test_code');
11286
$this->stateMock->expects($this->once())
11387
->method('getMode')
11488
->willReturn(State::MODE_PRODUCTION);
@@ -120,25 +94,19 @@ public function testHandleDisabledByProduction()
12094

12195
public function testHandleDisabledByConfig()
12296
{
123-
$this->storeMock->expects($this->once())
124-
->method('getCode')
125-
->willReturn('test_code');
12697
$this->stateMock->expects($this->once())
12798
->method('getMode')
12899
->willReturn(State::MODE_DEVELOPER);
129100
$this->scopeConfigMock->expects($this->once())
130101
->method('getValue')
131-
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, 'test_code')
102+
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null)
132103
->willReturn(false);
133104

134105
$this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]);
135106
}
136107

137108
public function testHandleDisabledByLevel()
138109
{
139-
$this->storeMock->expects($this->once())
140-
->method('getCode')
141-
->willReturn('test_code');
142110
$this->stateMock->expects($this->never())
143111
->method('getMode');
144112
$this->scopeConfigMock->expects($this->never())

0 commit comments

Comments
 (0)