[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [18634] Improved logging; log php errors for easier d
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] [18634] Improved logging; log php errors for easier debugging. |
Date: |
Thu, 03 Jul 2008 19:15:05 +0000 |
Revision: 18634
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18634
Author: johang
Date: 2008-07-03 19:15:04 +0000 (Thu, 03 Jul 2008)
Log Message:
-----------
Improved logging; log php errors for easier debugging.
Modified Paths:
--------------
trunk/syncml/inc/class.syncml_logger.inc.php
trunk/syncml/inc/constants.inc.php
trunk/syncml/syncml.php
Modified: trunk/syncml/inc/class.syncml_logger.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_logger.inc.php 2008-07-02 16:50:08 UTC
(rev 18633)
+++ trunk/syncml/inc/class.syncml_logger.inc.php 2008-07-03 19:15:04 UTC
(rev 18634)
@@ -23,6 +23,11 @@
{
$this->handle = fopen(SYNCML_DEBUG_FILE, 'a');
$this->log_run = substr(md5(microtime()), 0, 4);
+
+ if(SYNCML_DEBUG_MODE) {
+ fwrite($this->handle, sprintf("== new run (%s)
==\n",
+ date('H:i:s')));
+ }
}
static function get_instance()
@@ -43,6 +48,14 @@
}
}
+ function log_error($errno, $errstr, $errfile, $errline) {
+ if(SYNCML_DEBUG_MODE) {
+ fwrite(
+ $this->handle,
+ sprintf("%s, error: %s\n",
$this->log_run, $errstr));
+ }
+ }
+
function log($message)
{
if(SYNCML_DEBUG_MODE) {
Modified: trunk/syncml/inc/constants.inc.php
===================================================================
--- trunk/syncml/inc/constants.inc.php 2008-07-02 16:50:08 UTC (rev 18633)
+++ trunk/syncml/inc/constants.inc.php 2008-07-03 19:15:04 UTC (rev 18634)
@@ -14,7 +14,8 @@
* Debug properties.
*/
define('SYNCML_DEBUG_MODE', true);
- define('SYNCML_DEBUG_FILE', '/tmp/phpgw');
+ define('SYNCML_DEBUG_FILE', '/tmp/phpgw/debug.txt');
+ define('SYNCML_LOG_DIR', '/tmp/phpgw');
/**
* DEVID string used by DEVINF response.
Modified: trunk/syncml/syncml.php
===================================================================
--- trunk/syncml/syncml.php 2008-07-02 16:50:08 UTC (rev 18633)
+++ trunk/syncml/syncml.php 2008-07-03 19:15:04 UTC (rev 18634)
@@ -12,9 +12,6 @@
ob_start();
- error_reporting(E_ALL);
- // error_reporting(0);
-
$phpgw_info = array();
$GLOBALS['phpgw_info']['flags'] = array(
@@ -38,18 +35,26 @@
require_once 'inc/class.syncml_message.inc.php';
$file_date = gettimeofday(true);
+
// this is a ugly, ugly hack
//$GLOBALS['phpgw']->db->query('TRUNCATE phpgw_access_log');
+ set_error_handler(array(syncml_logger::get_instance(), 'log_error'),
E_ALL);
+
if(!isset($_SERVER['CONTENT_TYPE']) ||
$_SERVER['REQUEST_METHOD'] != 'POST')
{
+ syncml_logger::get_instance()->log_data(
+ "Unset content type or request method",
$_SERVER['REQUEST_METHOD']);
exit('I\'m a SyncML server (1)');
}
$post_input = implode("\r\n", file('php://input'));
- file_put_contents('/tmp/'.$file_date.'-a.xml', $post_input);
+ file_put_contents(
+ sprintf("%s/%s-input.xml", SYNCML_LOG_DIR, $file_date),
+ $post_input . "\n");
+
switch($_SERVER['CONTENT_TYPE'])
{
case 'application/vnd.syncml+wbxml':
@@ -83,15 +88,19 @@
// execute and print everything
$message->execute($response);
-
$response->print_response();
- file_put_contents('/tmp/'.$file_date.'-b.xml', ob_get_contents()."\n");
+ file_put_contents(
+ sprintf("%s/%s-output.xml", SYNCML_LOG_DIR, $file_date),
+ ob_get_contents() . "\n");
+
if($_SERVER['CONTENT_TYPE'] == 'application/vnd.syncml+wbxml')
{
// remove the xml declaration tag
$xml = substr(ob_get_clean(), 38);
+
ob_start();
+
// replace some bogus FPI values
echo str_replace(
array(
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [18634] Improved logging; log php errors for easier debugging.,
Johan Gunnarsson <=