3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Developer \Model \Logger \Handler ;
7
9
10
+ use Exception ;
8
11
use Magento \Config \Setup \ConfigOptionsList ;
9
- use Magento \Framework \App \Config \ ScopeConfigInterface ;
12
+ use Magento \Framework \App \DeploymentConfig ;
10
13
use Magento \Framework \App \State ;
14
+ use Magento \Framework \Exception \FileSystemException ;
15
+ use Magento \Framework \Exception \RuntimeException ;
11
16
use Magento \Framework \Filesystem \DriverInterface ;
12
- use Magento \Framework \App \ DeploymentConfig ;
17
+ use Magento \Framework \Logger \ Handler \ Debug as DebugHandler ;
13
18
14
19
/**
15
20
* Enable/disable debug logging based on the store config setting
16
21
*/
17
- class Debug extends \ Magento \ Framework \ Logger \ Handler \Debug
22
+ class Debug extends DebugHandler
18
23
{
19
24
/**
20
25
* @var State
@@ -30,14 +35,14 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
30
35
* @param DriverInterface $filesystem
31
36
* @param State $state
32
37
* @param DeploymentConfig $deploymentConfig
33
- * @param string $filePath
34
- * @throws \ Exception
38
+ * @param string|null $filePath
39
+ * @throws Exception
35
40
*/
36
41
public function __construct (
37
42
DriverInterface $ filesystem ,
38
43
State $ state ,
39
44
DeploymentConfig $ deploymentConfig ,
40
- $ filePath = null
45
+ ? string $ filePath = null
41
46
) {
42
47
parent ::__construct ($ filesystem , $ filePath );
43
48
@@ -48,30 +53,34 @@ public function __construct(
48
53
/**
49
54
* @inheritdoc
50
55
*/
51
- public function isHandling (array $ record )
56
+ public function isHandling (array $ record ): bool
52
57
{
53
58
if ($ this ->deploymentConfig ->isAvailable ()) {
54
- return
55
- parent ::isHandling ($ record )
56
- && $ this ->isLoggingEnabled ();
59
+ return parent ::isHandling ($ record ) && $ this ->isLoggingEnabled ();
57
60
}
58
61
59
62
return parent ::isHandling ($ record );
60
63
}
61
64
62
65
/**
63
- * Check that logging functionality is enabled.
66
+ * Check that logging functionality is enabled
64
67
*
65
68
* @return bool
69
+ * @throws FileSystemException
70
+ * @throws RuntimeException
66
71
*/
67
72
private function isLoggingEnabled (): bool
68
73
{
69
- $ configValue = $ this ->deploymentConfig ->get (ConfigOptionsList::CONFIG_PATH_DEBUG_LOGGING );
74
+ $ configValue = $ this ->deploymentConfig ->get (
75
+ ConfigOptionsList::CONFIG_PATH_DEBUG_LOGGING
76
+ );
77
+
70
78
if ($ configValue === null ) {
71
79
$ isEnabled = $ this ->state ->getMode () !== State::MODE_PRODUCTION ;
72
80
} else {
73
- $ isEnabled = (bool )$ configValue ;
81
+ $ isEnabled = (bool ) $ configValue ;
74
82
}
83
+
75
84
return $ isEnabled ;
76
85
}
77
86
}
0 commit comments