phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [18521] forgot to add the new logging class.


From: Johan Gunnarsson
Subject: [Phpgroupware-cvs] [18521] forgot to add the new logging class.
Date: Thu, 08 May 2008 22:19:40 +0000

Revision: 18521
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18521
Author:   johang
Date:     2008-05-08 22:19:39 +0000 (Thu, 08 May 2008)

Log Message:
-----------
forgot to add the new logging class. here it is.

Added Paths:
-----------
    trunk/syncml/inc/class.syncml_logger.inc.php

Added: trunk/syncml/inc/class.syncml_logger.inc.php
===================================================================
--- trunk/syncml/inc/class.syncml_logger.inc.php                                
(rev 0)
+++ trunk/syncml/inc/class.syncml_logger.inc.php        2008-05-08 22:19:39 UTC 
(rev 18521)
@@ -0,0 +1,53 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License 3 or later
+        * @package   syncml
+        * @version   $Id: class.sodatabase.inc.php 18394 2008-02-02 10:34:41Z 
skwashd $
+        */
+
+       /**
+        * Manage logging.
+        */
+       class syncml_logger
+       {
+               private $handle;
+
+               static private $instance;
+
+               function syncml_logger()
+               {
+                       $this->handle = fopen(SYNCML_DEBUG_FILE, 'a');
+                       $this->log_run = substr(md5(microtime()), 0, 4);
+               }
+
+               static function get_instance()
+               {
+                       if(is_null(self::$instance)) {
+                               self::$instance = new syncml_logger();
+                       }
+
+                       return self::$instance;
+               }
+
+               function log_data($message, $data)
+               {
+                       if(SYNCML_DEBUG_MODE) {
+                               fwrite($this->handle, sprintf("%s, %s, %s, 
%s\n",
+                                       $this->log_run, date('H:i:s'), $message,
+                                       var_export($data, true)));
+                       }
+               }
+
+               function log($message)
+               {
+                       if(SYNCML_DEBUG_MODE) {
+                               fwrite($this->handle, sprintf("%s, %s, %s\n",
+                                       $this->log_run, date('H:i:s'), 
$message));
+                       }
+               }
+       }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]