1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ApacheSolrForTypo3\Solr\System\Logging; |
4
|
|
|
|
5
|
|
|
/*************************************************************** |
6
|
|
|
* Copyright notice |
7
|
|
|
* |
8
|
|
|
* (c) 2010-2016 Timo Hund <[email protected] |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use ApacheSolrForTypo3\Solr\Util; |
29
|
|
|
use TYPO3\CMS\Core\Utility\DebugUtility; |
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
31
|
|
|
use TYPO3\CMS\Extbase\Utility\DebuggerUtility; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The DebugWriter is used to write the devLog messages to the output of the page, or to the TYPO3 console in the |
35
|
|
|
* backend to provide a simple and lightweigt debugging possibility. |
36
|
|
|
* |
37
|
|
|
* @author Timo Hund <[email protected]> |
38
|
|
|
*/ |
39
|
|
|
class DebugWriter |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* When the feature is enabled with: plugin.tx_solr.logging.debugOutput the log writer uses the extbase |
44
|
|
|
* debug functionality in the frontend, or the console in the backend to display the devlog messages. |
45
|
|
|
* |
46
|
|
|
* @param int|string $level Log level. Value according to \TYPO3\CMS\Core\Log\LogLevel. Alternatively accepts a string. |
47
|
|
|
* @param string $message Log message. |
48
|
|
|
* @param array $data Additional data to log |
49
|
|
|
*/ |
50
|
56 |
|
public function write($level, $message, $data = []) |
51
|
|
|
{ |
52
|
56 |
|
$debugAllowedForIp = $this->getIsAllowedByDevIPMask(); |
53
|
56 |
|
if (!$debugAllowedForIp) { |
54
|
54 |
|
return; |
55
|
|
|
} |
56
|
|
|
|
57
|
2 |
|
$isDebugOutputEnabled = $this->getIsDebugOutputEnabled(); |
58
|
2 |
|
if (!$isDebugOutputEnabled) { |
59
|
1 |
|
return; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
$this->writeDebugMessage($level, $message, $data); |
63
|
1 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
53 |
|
protected function getIsAllowedByDevIPMask() |
69
|
|
|
{ |
70
|
53 |
|
return GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Check if Logging via debugOutput has been configured |
75
|
|
|
* |
76
|
|
|
* @return bool |
77
|
|
|
*/ |
78
|
|
|
protected function getIsDebugOutputEnabled() |
79
|
|
|
{ |
80
|
|
|
return Util::getSolrConfiguration()->getLoggingDebugOutput(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param int|string $level Log level. Value according to \TYPO3\CMS\Core\Log\LogLevel. Alternatively accepts a string. |
85
|
|
|
* @param string $message Log message. |
86
|
|
|
* @param array $data Additional data to log |
87
|
|
|
*/ |
88
|
|
|
protected function writeDebugMessage($level, $message, $data) |
89
|
|
|
{ |
90
|
|
|
$parameters = ['extKey' => 'solr', 'msg' => $message, 'level' => $level, 'data' => $data]; |
91
|
|
|
$message = isset($parameters['msg']) ? $parameters['msg'] : ''; |
92
|
|
|
if (TYPO3_MODE == 'BE') { |
93
|
|
|
DebugUtility::debug($parameters, $parameters['extKey'], 'DevLog ext:solr: ' . $message); |
|
|
|
|
94
|
|
|
} else { |
95
|
|
|
echo $message . ':<br/>'; |
96
|
|
|
DebuggerUtility::var_dump($parameters); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: