From 11d5e7c1002ec281c57b1181487e448b91e19b80 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 12 May 2015 13:50:02 -0400
Subject: [PATCH] Implemented memcache_debug also for session operations

---
 program/lib/Roundcube/rcube.php |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index cf6ebf9..ae5957e 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -37,6 +37,8 @@
     const REQUEST_ERROR_URL   = 1;
     const REQUEST_ERROR_TOKEN = 2;
 
+    const DEBUG_LINE_LENGTH = 4096;
+
     /**
      * Singleton instace of rcube
      *
@@ -1453,6 +1455,32 @@
 
 
     /**
+     * Write debug info to the log
+     *
+     * @param string Engine type - file name (memcache, apc)
+     * @param string Data string to log
+     * @param bool   Operation result
+     */
+    public static function debug($engine, $data, $result = null)
+    {
+        static $debug_counter;
+
+        $line = '[' . (++$debug_counter[$engine]) . '] ' . $data;
+
+        if (($len = strlen($line)) > self::DEBUG_LINE_LENGTH) {
+            $diff = $len - self::DEBUG_LINE_LENGTH;
+            $line = substr($line, 0, self::DEBUG_LINE_LENGTH) . "... [truncated $diff bytes]";
+        }
+
+        if ($result !== null) {
+            $line .= ' [' . ($result ? 'TRUE' : 'FALSE') . ']';
+        }
+
+        self::write_log($engine, $line);
+    }
+
+
+    /**
      * Returns current time (with microseconds).
      *
      * @return float Current time in seconds since the Unix

--
Gitblit v1.9.1