Changeset 18796


Ignore:
Timestamp:
2010/09/06 15:05:17 (10 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18795
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/class/SC_Query.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_Query.php
html/handle_error.php 18500@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fversion-2_4-dev%2Fhtml%2Fhandle_error.php
bzr:mapping-version:
v4
bzr:merge:

ohkouchi@loop-az.jp-20100906060112-k8mh0ss02zk1s0ov
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20100906060514-lc92335xfz5nsfsk
bzr:revno:
2279
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-revisions:

data/class/SC_Query.php ohkouchi@loop-az.jp-20100906060112-k8mh0ss02zk1s0ov
html/handle_error.php ohkouchi@loop-az.jp-20100906060112-k8mh0ss02zk1s0ov
bzr:timestamp:
2010-09-06 15:05:14.325000048 +0900
bzr:user-agent:
bzr2.2.0+bzr-svn1.0.3
svn:original-date:
2010-09-06T06:05:14.325000Z
Message:

エラーログ出力の改善(#567)

  • SC_Query::$force_run のデフォルト値を false へ修正
  • エラーの詳細を data/logs/site.log へ出力するように修正
Location:
branches/version-2_5-dev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/SC_Query.php

    r18790 r18796  
    4949     * @param boolean $new 新規に接続を行うかどうか 
    5050     */ 
    51     function SC_Query($dsn = "", $force_run = true, $new = false) { 
     51    function SC_Query($dsn = "", $force_run = false, $new = false) { 
    5252 
    5353        if ($dsn == "") { 
     
    754754        if (PEAR::isError($sth)) { 
    755755            if (!$this->force_run) { 
    756                trigger_error($sth->getMessage(), E_USER_ERROR); 
     756                trigger_error($this->traceError($sth, $sql), E_USER_ERROR); 
     757            } else { 
     758                error_log($this->traceError($sth, $sql), 3, LOG_PATH); 
    757759            } 
    758760        } 
     
    772774        if (PEAR::isError($affected)) { 
    773775            if (!$this->force_run) { 
    774                trigger_error($affected->getMessage(), E_USER_ERROR); 
     776                trigger_error($this->traceError($affected), E_USER_ERROR); 
     777            } else { 
     778                error_log($this->traceError($affected), 3, LOG_PATH); 
    775779            } 
    776780        } 
    777781        return $affected; 
    778782    } 
     783 
     784    /** 
     785     * エラーの内容をトレースする. 
     786     * 
     787     * @access private 
     788     * @param PEAR::Error $error PEAR::Error インスタンス 
     789     * @param string $sql エラーの発生した SQL 文 
     790     * @return string トレースしたエラー文字列 
     791     */ 
     792    function traceError($error, $sql = "") { 
     793        $scheme = ''; 
     794        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { 
     795            $scheme = "http://"; 
     796        } else { 
     797            $scheme = "https://"; 
     798        } 
     799 
     800        $err = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n\n" 
     801            . "SERVER_ADDR: " . $_SERVER['SERVER_ADDR'] . "\n" 
     802            . "REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'] . "\n" 
     803            . "USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n\n" 
     804            . "SQL: " . $sql . "\n\n" 
     805            . $error->getMessage() . "\n\n" 
     806            . $error->getUserInfo() . "\n\n"; 
     807 
     808        $rev = array_reverse($error->getBackTrace()); 
     809 
     810        foreach($rev as $val) { 
     811            if($val['class'] != "") { 
     812                $detail = $val['class'] . "->" . $val['function']; 
     813            } else { 
     814                $detail = $val['function']; 
     815            } 
     816            $err .= $val['file'] . " " . $val['line'] . ":" . $detail . "\n"; 
     817        } 
     818        return $err; 
     819    } 
    779820} 
    780821 
  • branches/version-2_5-dev/html/handle_error.php

    r18743 r18796  
    7474    case E_USER_ERROR: 
    7575        ob_end_clean(); 
    76         error_log("FATAL Error($errno) $errfile:$errline $errstr"); 
     76        error_log("FATAL Error($errno) $errfile:$errline $errstr", 3, LOG_PATH); 
    7777 
    7878        $admin = ""; 
Note: See TracChangeset for help on using the changeset viewer.