Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       79.45%  | 
       58 / 73  | 
               | 
       70.00%  | 
       7 / 10  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| common_log_Item |         | 
       79.45%  | 
       58 / 73  | 
               | 
       70.00%  | 
       7 / 10  | 
       39.34 |         | 
       0.00%  | 
       0 / 1  | 
      
| __construct |         | 
       72.73%  | 
       24 / 33  | 
               | 
       0.00%  | 
       0 / 1  | 
       19.56 | |||
| getDateTime |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getDescription |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getSeverity |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getBacktrace |         | 
       0.00%  | 
       0 / 3  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| getRequest |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getCallerFile |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getCallerLine |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getTags |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| getSeverityDescriptionString |         | 
       81.25%  | 
       13 / 16  | 
               | 
       0.00%  | 
       0 / 1  | 
       8.42 | |||
| 1 | <?php | 
| 2 | |
| 3 | /** | 
| 4 | * This program is free software; you can redistribute it and/or | 
| 5 | * modify it under the terms of the GNU General Public License | 
| 6 | * as published by the Free Software Foundation; under version 2 | 
| 7 | * of the License (non-upgradable). | 
| 8 | * | 
| 9 | * This program is distributed in the hope that it will be useful, | 
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 | * GNU General Public License for more details. | 
| 13 | * | 
| 14 | * You should have received a copy of the GNU General Public License | 
| 15 | * along with this program; if not, write to the Free Software | 
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
| 17 | * | 
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg | 
| 19 | * (under the project TAO & TAO2); | 
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung | 
| 21 | * (under the project TAO-TRANSFER); | 
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor | 
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); | 
| 24 | * 2013 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT); | 
| 25 | * | 
| 26 | */ | 
| 27 | |
| 28 | /** | 
| 29 | * Short description of class common_log_Item | 
| 30 | * | 
| 31 | * @access public | 
| 32 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 33 | * @package generis | 
| 34 | |
| 35 | */ | 
| 36 | class common_log_Item | 
| 37 | { | 
| 38 | /** | 
| 39 | * Short description of attribute datetime | 
| 40 | * | 
| 41 | * @access private | 
| 42 | * @var int | 
| 43 | */ | 
| 44 | private $datetime = 0; | 
| 45 | |
| 46 | /** | 
| 47 | * Short description of attribute description | 
| 48 | * | 
| 49 | * @access private | 
| 50 | * @var string | 
| 51 | */ | 
| 52 | private $description = ''; | 
| 53 | |
| 54 | /** | 
| 55 | * Short description of attribute severity | 
| 56 | * | 
| 57 | * @access private | 
| 58 | * @var int | 
| 59 | */ | 
| 60 | private $severity = 0; | 
| 61 | |
| 62 | /** | 
| 63 | * Short description of attribute backtrace | 
| 64 | * | 
| 65 | * @access private | 
| 66 | * @var array | 
| 67 | */ | 
| 68 | private $backtrace = []; | 
| 69 | |
| 70 | /** | 
| 71 | * Short description of attribute request | 
| 72 | * | 
| 73 | * @access private | 
| 74 | * @var string | 
| 75 | */ | 
| 76 | private $request = ''; | 
| 77 | |
| 78 | /** | 
| 79 | * Short description of attribute tags | 
| 80 | * | 
| 81 | * @access private | 
| 82 | * @var array | 
| 83 | */ | 
| 84 | private $tags = []; | 
| 85 | |
| 86 | /** | 
| 87 | * Short description of attribute errorFile | 
| 88 | * | 
| 89 | * @access private | 
| 90 | * @var string | 
| 91 | */ | 
| 92 | private $errorFile = ''; | 
| 93 | |
| 94 | /** | 
| 95 | * Short description of attribute errorLine | 
| 96 | * | 
| 97 | * @access private | 
| 98 | * @var int | 
| 99 | */ | 
| 100 | private $errorLine = 0; | 
| 101 | |
| 102 | /** | 
| 103 | * Short description of method __construct | 
| 104 | * | 
| 105 | * @access public | 
| 106 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 107 | * @param string description | 
| 108 | * @param int severity | 
| 109 | * @param int datetime | 
| 110 | * @param string user | 
| 111 | * @param array backtrace | 
| 112 | * @param array tags | 
| 113 | * @param string request | 
| 114 | * @param string errorFile | 
| 115 | * @param int errorLine | 
| 116 | * @return mixed | 
| 117 | */ | 
| 118 | public function __construct( | 
| 119 | $description, | 
| 120 | $severity, | 
| 121 | $datetime, | 
| 122 | $backtrace = [], | 
| 123 | $tags = [], | 
| 124 | $request = "", | 
| 125 | $errorFile = '', | 
| 126 | $errorLine = 0 | 
| 127 | ) { | 
| 128 | if (!is_string($description)) { | 
| 129 | throw new InvalidArgumentException("The description must be a string, " . gettype($description) . " given"); | 
| 130 | } | 
| 131 | |
| 132 | $this->description = $description; | 
| 133 | $this->severity = $severity; | 
| 134 | $this->datetime = $datetime; | 
| 135 | $this->tags = is_array($tags) ? $tags : [$tags]; | 
| 136 | $this->request = $request; | 
| 137 | $this->errorFile = $errorFile; | 
| 138 | $this->errorLine = $errorLine; | 
| 139 | |
| 140 | // limit backtrace | 
| 141 | if (count($backtrace) > 50) { | 
| 142 | $backtrace = array_slice($backtrace, -50); | 
| 143 | } | 
| 144 | |
| 145 | $cleanbacktrace = []; | 
| 146 | foreach ($backtrace as $key => $row) { | 
| 147 | if (isset($backtrace[$key]['object'])) { | 
| 148 | unset($backtrace[$key]['object']); | 
| 149 | } | 
| 150 | |
| 151 | // WARNING | 
| 152 | // do NOT modify the variables in the backtrace directly or | 
| 153 | // objects passed by reference will be modified aswell | 
| 154 | if (isset($backtrace[$key]['args'])) { | 
| 155 | $vars = []; | 
| 156 | foreach ($backtrace[$key]['args'] as $k => $v) { | 
| 157 | switch (gettype($v)) { | 
| 158 | case 'boolean': | 
| 159 | case 'integer': | 
| 160 | case 'double': | 
| 161 | $vars[$k] = (string)$v; | 
| 162 | break; | 
| 163 | case 'string': | 
| 164 | $vars[$k] = strlen($v) > 128 ? 'string(' . strlen($v) . ')' : $v; | 
| 165 | break; | 
| 166 | case 'class': | 
| 167 | $vars[$k] = get_class($v); | 
| 168 | break; | 
| 169 | default: | 
| 170 | $vars[$k] = gettype($v); | 
| 171 | } | 
| 172 | } | 
| 173 | $backtrace[$key]['args'] = $vars; | 
| 174 | } | 
| 175 | } | 
| 176 | $this->backtrace = $backtrace; | 
| 177 | } | 
| 178 | |
| 179 | /** | 
| 180 | * Short description of method getDateTime | 
| 181 | * | 
| 182 | * @access public | 
| 183 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 184 | * @return int | 
| 185 | */ | 
| 186 | public function getDateTime() | 
| 187 | { | 
| 188 | $returnValue = (int) 0; | 
| 189 | |
| 190 | $returnValue = $this->datetime; | 
| 191 | |
| 192 | return (int) $returnValue; | 
| 193 | } | 
| 194 | |
| 195 | /** | 
| 196 | * Short description of method getDescription | 
| 197 | * | 
| 198 | * @access public | 
| 199 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 200 | * @return string | 
| 201 | */ | 
| 202 | public function getDescription() | 
| 203 | { | 
| 204 | $returnValue = (string) ''; | 
| 205 | |
| 206 | $returnValue = $this->description; | 
| 207 | |
| 208 | return (string) $returnValue; | 
| 209 | } | 
| 210 | |
| 211 | /** | 
| 212 | * Short description of method getSeverity | 
| 213 | * | 
| 214 | * @access public | 
| 215 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 216 | * @return int | 
| 217 | */ | 
| 218 | public function getSeverity() | 
| 219 | { | 
| 220 | $returnValue = (int) 0; | 
| 221 | |
| 222 | $returnValue = $this->severity; | 
| 223 | |
| 224 | return (int) $returnValue; | 
| 225 | } | 
| 226 | |
| 227 | /** | 
| 228 | * Short description of method getBacktrace | 
| 229 | * | 
| 230 | * @access public | 
| 231 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 232 | * @return array | 
| 233 | */ | 
| 234 | public function getBacktrace() | 
| 235 | { | 
| 236 | $returnValue = []; | 
| 237 | |
| 238 | $returnValue = $this->backtrace; | 
| 239 | |
| 240 | return (array) $returnValue; | 
| 241 | } | 
| 242 | |
| 243 | /** | 
| 244 | * Short description of method getRequest | 
| 245 | * | 
| 246 | * @access public | 
| 247 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 248 | * @return string | 
| 249 | */ | 
| 250 | public function getRequest() | 
| 251 | { | 
| 252 | $returnValue = (string) ''; | 
| 253 | |
| 254 | $returnValue = $this->request; | 
| 255 | |
| 256 | return (string) $returnValue; | 
| 257 | } | 
| 258 | |
| 259 | /** | 
| 260 | * Short description of method getCallerFile | 
| 261 | * | 
| 262 | * @access public | 
| 263 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 264 | * @return string | 
| 265 | */ | 
| 266 | public function getCallerFile() | 
| 267 | { | 
| 268 | $returnValue = (string) ''; | 
| 269 | |
| 270 | $returnValue = $this->errorFile; | 
| 271 | |
| 272 | return (string) $returnValue; | 
| 273 | } | 
| 274 | |
| 275 | /** | 
| 276 | * Short description of method getCallerLine | 
| 277 | * | 
| 278 | * @access public | 
| 279 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 280 | * @return int | 
| 281 | */ | 
| 282 | public function getCallerLine() | 
| 283 | { | 
| 284 | $returnValue = (int) 0; | 
| 285 | |
| 286 | $returnValue = $this->errorLine; | 
| 287 | |
| 288 | return (int) $returnValue; | 
| 289 | } | 
| 290 | |
| 291 | /** | 
| 292 | * Short description of method getTags | 
| 293 | * | 
| 294 | * @access public | 
| 295 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 296 | * @return array | 
| 297 | */ | 
| 298 | public function getTags() | 
| 299 | { | 
| 300 | $returnValue = []; | 
| 301 | |
| 302 | $returnValue = $this->tags; | 
| 303 | |
| 304 | return (array) $returnValue; | 
| 305 | } | 
| 306 | |
| 307 | /** | 
| 308 | * Short description of method getSeverityDescriptionString | 
| 309 | * | 
| 310 | * @access public | 
| 311 | * @author Joel Bout, <joel.bout@tudor.lu> | 
| 312 | * @return string | 
| 313 | */ | 
| 314 | public function getSeverityDescriptionString() | 
| 315 | { | 
| 316 | $returnValue = (string) ''; | 
| 317 | |
| 318 | switch ($this->severity) { | 
| 319 | case common_Logger::TRACE_LEVEL: | 
| 320 | $returnValue = "TRACE"; | 
| 321 | break; | 
| 322 | case common_Logger::DEBUG_LEVEL: | 
| 323 | $returnValue = "DEBUG"; | 
| 324 | break; | 
| 325 | case common_Logger::INFO_LEVEL: | 
| 326 | $returnValue = "INFO"; | 
| 327 | break; | 
| 328 | case common_Logger::WARNING_LEVEL: | 
| 329 | $returnValue = "WARNING"; | 
| 330 | break; | 
| 331 | case common_Logger::ERROR_LEVEL: | 
| 332 | $returnValue = "ERROR"; | 
| 333 | break; | 
| 334 | case common_Logger::FATAL_LEVEL: | 
| 335 | $returnValue = "FATAL"; | 
| 336 | break; | 
| 337 | default: | 
| 338 | $returnValue = "UNKNOWN"; | 
| 339 | } | 
| 340 | |
| 341 | return (string) $returnValue; | 
| 342 | } | 
| 343 | } |