EXT/cc devlog/testing
From TYPO3Wiki
<< Back to Extension manuals page
By: Sylvain Viart 11:50, 10 Nov 2004 (CET)
Contents |
CCDevLog
Extension link T3Ext:cc_devlog
This page is about testing the CCDevLog extension.
This extension is for TYPO3 developers. It allows you to catch and view TYPO3 debugging / logging messages. CCDevLog is reported to work with TYPO3 3.7.0-dev. It is also not well documented and reserved for programmers. Like to eat code, follow me. ;-)
Test context:
- TYPO3 3.7.0
- Debian Linux Sarge
- PHP Version 4.3.4
- Server API: Apache
- Apache Version: Apache/1.3.31
- MySQL Client API version: 3.23.56
- MySQL Server version: 4.0.21-log
Usage
In the PHP code, messages caught by this logger are introduced by this kind of code:
if (TYPO3_DLOG) t3lib_div::devLog('Entering encodeSpURL for '
.$params['LD']['totalURL'], 'realurl');
The constant TYPO3_DLOG is defined in t3lib/config_default.php
// Define "TYPO3_DLOG" constant
define('TYPO3_DLOG', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']);
To enable devlopper loggin facility, in my localconf.php I add the following line:
$TYPO3_CONF_VARS['SYS']['enable_DLOG']=1;
Logging in the code
Here an example of log in the code of RealURL extention
// log only if enabled
if (TYPO3_DLOG)
t3lib_div::devLog(
'encodeSpURL_setSequence:param', // text message
'realurl', // extension name
0, // severity (icon)
array('varSetCfg' => $varSetCfg, // extra data
'paramKeyValues' => $paramKeyValues,
'pathParts' => $pathParts));
Severity value:
- 0 info
- 1 notice
- 2 warning
- 3 fatal error
- -1 is "OK" message
Extra_data are serialised in the database. The current extension doesn't show this data. I've added a popup box which show the print_r() of the deserialized data.
Viewing the log
In the BE select the extension icon in admin list (Tools).
Displaying of extra_data, with patched version
CCDevLog patch
Unified diff patch for the popup.
Also add in mod1/locallang.php: line 20
'clear_button' => 'Clear all log',
mod1/index.php
<nowiki>
--- index_orig.php 2004-11-18 21:42:52.000000000 +0100
+++ index.php 2004-11-18 06:21:45.000000000 +0100
@@ -157,16 +157,18 @@
$onClick = 'toggleReload(this.checked);';
$optMenu['autorefresh'] .= '<input type="checkbox" name="SET[autorefresh]" value="1"'.($this->MOD_SETTINGS['autorefresh']?' checked':'').' onclick="'.htmlspecialchars($onClick).'"> '.$LANG->getLL('auto_refresh');
}
- $optMenu['refresh'] = '<input type="submit" name="refresh" value="'.$LANG->getLL('refresh').'">';;
+ $optMenu['refresh'] = '<input type="submit" name="action_button" value="'.$LANG->getLL('refresh').'">';;
+ $optMenu['clear'] = '<input type="submit" name="action_button" '.
+ 'value="'.$LANG->getLL('clear_button').'">';;
$headerSection = $this->doc->menuTable(
array(
array('Select Log:',$optMenu['sellogrun']),
- array('',$optMenu['refresh'])
+ array('',$optMenu['refresh']),
),
array(
array('',$optMenu['autorefresh']),
- array('','')
+ array('',$optMenu['clear'])
)
);
}
@@ -215,8 +217,15 @@
* Generates the module content
*/
function moduleContent() {
+ global $LANG;
switch((string)$this->MOD_SETTINGS['function']) {
case 'showlog':
+ $action_button = t3lib_div::_POST('action_button');
+ if($action_button == $LANG->getLL('clear_button')) {
+ // delete all table entries
+ $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_ccdevlog', '');
+ }
+
if(count($this->logRuns)) {
$content = $this->getLogTable($$this->selectedLog);
$this->content.=$this->doc->section('DevLog:',$content,0,1);
@@ -257,6 +266,7 @@
// add header row
$table[$tr][] =' ';
$table[$tr][] =' ';
+ $table[$tr][] ='logDate';
$table[$tr][] ='extKey';
$table[$tr][] ='message';
$table[$tr][] ='page';
@@ -299,11 +309,12 @@
$table[$tr][] = $tr;
$table[$tr][] = $severity;
+ $table[$tr][] = t3lib_befunc::dateTimeAge($row['crdate']);
$table[$tr][] = $row['extkey'];
$table[$tr][] = htmlspecialchars($row['msg']);
$table[$tr][] = $this->getItemFromRecord('pages', array('uid' => $row['pid']));
- $table[$tr][] = $row['cruser'];
- $table[$tr][] = $row['data_var'] ? 'X' : '';
+ $table[$tr][] = $row['cruser_id'];
+ $table[$tr][] = $this->showExtra_data($row['data_var']);
}
@@ -429,6 +440,32 @@
return '<a href="#" onclick="'.htmlspecialchars($editOnClick).'">'.$str.'</a>'; ;
}
+ /**
+ * Create a link which display a new window with the serialized data
+ */
+ function showExtra_data($serialized) {
+
+ if(!$serialized)
+ return;
+
+ $content = unserialize(stripslashes($serialized));
+ ob_start();
+ print_r($content);
+ $print_r_str = ob_get_contents();
+ ob_end_clean();
+
+ $res = $print_r_str ? $print_r_str : $serialized;
+ $res = '<pre>'.str_replace("\n", '\n',$res).' ';
+ $onClick =" +ccdevlogWinData=window.open(,'ccdevlog_data','width=790,status=0,menubar=1,resizable=1,location=0,scrollbars=1,toolbar=0'); +ccdevlog_data_doc=ccdevlogWinData.document.open(); +ccdevlog_data_doc.write(\"$res\"); +ccdevlog_data_doc.close(); +ccdevlogWinData.focus(); +return false; +"; + return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.'X</a>'; + }
}
@@ -447,4 +484,4 @@
$SOBE->main(); $SOBE->printContent();
-?> \ No newline at end of file +?> </nowiki> </pre>
