public function renderOutput()
 {
     return json_encode(array("version" => COMPONENT_VERSION, "caller" => $this->_caller, "callee" => COMPONENT_NAME, "eventId" => $this->_eventId, "timestamp" => time(), "returnValue" => $this->_retValue, "returnMsg" => genErrMsg($this->_retValue, $this->_retMsg), "returnData" => $this->_data));
 }
Exemple #2
0
 public function renderOutput()
 {
     $ret = array("timestamp" => time(), "retVal" => $this->_retValue, "retMsg" => genErrMsg($this->_retValue, $this->_retMsg), "retStr" => genRetStr($this->_retValue), "retData" => $this->_data);
     interface_log(DEBUG, 0, "ret:" . json_encode($ret));
     return $ret;
 }
/**
 * @author pacozhong
 * 日志函数的入口
 * @param string $confName 日志配置名
 * @param string $logLevel 级别
 * @param int $errorCode 错误码
 * @param string $logMessage 日志内容
 */
function _log($confName, $logLevel, $errorCode, $logMessage = "no error msg")
{
    if (isLogLevelOff($logLevel)) {
        return;
    }
    $st = debug_backtrace();
    $function = '';
    //调用interface_log/web_log的函数名
    $file = '';
    //调用interface_log/web_log的文件名
    $line = '';
    //调用interface_log/web_log的行号
    foreach ($st as $item) {
        if ($file) {
            $function = $item['function'];
            break;
        }
        if (substr($item['function'], -4) == '_log' && strlen($item['function']) > 4) {
            $file = $item['file'];
            $line = $item['line'];
        }
    }
    $function = $function ? $function : 'main';
    //为了缩短日志的输出,file只取最后一截文件名
    $file = explode("/", rtrim($file, '/'));
    $file = $file[count($file) - 1];
    $prefix = "[{$file}][{$function}][{$line}][{$logLevel}][{$errorCode}] ";
    //if($logLevel == INFO || $logLevel == STAT) {
    //	$prefix = "[$logLevel]" ;
    //}
    if ($errorCode) {
        $logMessage = genErrMsg($errorCode, $logMessage);
    }
    $logFileName = $confName . "_" . strtolower($logLevel);
    MiniLog::instance(ROOT_PATH . "/log/")->log($logFileName, $prefix . $logMessage);
    if (isLogLevelOff("DEBUG") || $logLevel == "DEBUG") {
        return;
    } else {
        MiniLog::instance(ROOT_PATH . "/log/")->log($confName . "_" . "debug", $prefix . $logMessage);
    }
}