Aleksander Machniak
2013-05-15 43079d8e2dbd8e195b63dd8fb9f5251ae7c66248
Simplify/fix debug lines truncation
3 files modified
19 ■■■■■ changed files
program/lib/Roundcube/rcube_db.php 5 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap_generic.php 7 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_smtp.php 7 ●●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_db.php
@@ -257,8 +257,9 @@
    {
        if ($this->options['debug_mode']) {
            if (($len = strlen($query)) > self::DEBUG_LINE_LENGTH) {
                $query = substr_replace($query, "\n-----[debug cut]-----\n",
                    self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
                $diff  = $len - self::DEBUG_LINE_LENGTH;
                $query = substr($query, 0, self::DEBUG_LINE_LENGTH)
                    . "... [truncated $diff bytes]";
            }
            rcube::write_log('sql', '[' . (++$this->db_index) . '] ' . $query . ';');
        }
program/lib/Roundcube/rcube_imap_generic.php
@@ -72,7 +72,7 @@
    const COMMAND_CAPABILITY = 2;
    const COMMAND_LASTLINE   = 4;
    const DEBUG_LINE_LENGTH = 4096;
    const DEBUG_LINE_LENGTH = 4098; // 4KB + 2B for \r\n
    /**
     * Object constructor
@@ -3780,8 +3780,9 @@
    private function debug($message)
    {
        if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) {
            $message = substr_replace($message, "\n-----[debug cut]-----\n",
                self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
            $diff    = $len - self::DEBUG_LINE_LENGTH;
            $message = substr($message, 0, self::DEBUG_LINE_LENGTH)
                . "... [truncated $diff bytes]";
        }
        if ($this->resourceid) {
program/lib/Roundcube/rcube_smtp.php
@@ -33,7 +33,7 @@
    // define headers delimiter
    const SMTP_MIME_CRLF = "\r\n";
    const DEBUG_LINE_LENGTH = 4096;
    const DEBUG_LINE_LENGTH = 4098; // 4KB + 2B for \r\n
    /**
@@ -330,8 +330,9 @@
    public function debug_handler(&$smtp, $message)
    {
        if (($len = strlen($message)) > self::DEBUG_LINE_LENGTH) {
            $message = substr_replace($message, "\n-----[debug cut]----\n",
                self::DEBUG_LINE_LENGTH/2 - 11, $len - self::DEBUG_LINE_LENGTH - 22);
            $diff    = $len - self::DEBUG_LINE_LENGTH;
            $message = substr($message, 0, self::DEBUG_LINE_LENGTH)
                . "... [truncated $diff bytes]";
        }
        rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message));