[BUGFIX] Moving files in filelist renames file to "1"
[Packages/TYPO3.CMS.git] / t3lib / log / processor / class.t3lib_log_processor_introspection.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Ingo Renner (ingo@typo3.org)
6 * (c) 2012 Steffen Müller (typo3@t3node.com)
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25
26
27 /**
28 * Introspection processor to automatically add where the log record came from.
29 *
30 * @author Ingo Renner <ingo@typo3.org>
31 * @package TYPO3
32 * @subpackage t3lib
33 */
34 class t3lib_log_processor_Introspection extends t3lib_log_processor_Abstract {
35
36 /**
37 * Add debug backtrace information to logRecord
38 * It adds: filepath, line number, class and function name
39 *
40 * @param t3lib_log_Record $logRecord The log record to process
41 * @return t3lib_log_Record The processed log record with additional data
42 * @see debug_backtrace()
43 */
44 public function processLogRecord(t3lib_log_Record $logRecord) {
45 $trace = debug_backtrace();
46
47 // skip first since it's always the current method
48 array_shift($trace);
49
50 // the call_user_func call is also skipped
51 array_shift($trace);
52
53 // skip t3lib_log classes
54 $i = 0;
55 while (isset($trace[$i]['class']) && FALSE !== strpos($trace[$i]['class'], 't3lib_log_')) {
56 $i++;
57 }
58
59 // we should have the call source now
60 $logRecord->addData(array(
61 'file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : NULL,
62 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : NULL,
63 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : NULL,
64 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : NULL,
65 ));
66
67 return $logRecord;
68 }
69
70 }
71
72 ?>