コード例 #1
2
 private function traceHttp()
 {
     $content = date('Y-m-d H:i:s') . "\nREMOTE_ADDR:" . $_SERVER["REMOTE_ADDR"] . "\nQUERY_STRING:" . $_SERVER["QUERY_STRING"] . "\n\n";
     if (isset($_SERVER['HTTP_APPNAME'])) {
         sae_set_display_errors(FALSE);
         sae_debug(trim($content));
         sae_set_display_errors(TRUE);
     } else {
         $max_size = 100000;
         $log_filename = "log.xml";
         if (file_exists($log_filename) and abs(filesize($log_filename)) > $max_size) {
             unlink($log_filename);
         }
         file_put_contents($log_filename, $content, FILE_APPEND);
     }
 }
コード例 #2
0
ファイル: sae.php プロジェクト: zhaomingliang/think
 /**
  * 日志写入接口
  * @access public
  * @param array $log 日志信息
  * @return void
  */
 public function save($log = [])
 {
     static $is_debug = null;
     $now = date($this->config['log_time_format']);
     // 获取基本信息
     if (isset($_SERVER['HTTP_HOST'])) {
         $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     } else {
         $current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
     }
     $runtime = number_format(microtime(true) - START_TIME, 6);
     $reqs = number_format(1 / $runtime, 2);
     $time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
     $memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
     $memory_str = " [内存消耗:{$memory_use}kb]";
     $file_load = " [文件加载:" . count(get_included_files()) . "]";
     array_unshift($log, ['type' => 'log', 'msg' => $current_uri . $time_str . $memory_str . $file_load]);
     $info = '';
     foreach ($log as $line) {
         $info .= '[' . $line['type'] . '] ' . $line['msg'] . "\r\n";
     }
     $logstr = "[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$info}\r\n";
     if (is_null($is_debug)) {
         preg_replace('@(\\w+)\\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
         $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
     }
     if ($is_debug) {
         sae_set_display_errors(false);
         //记录日志不将日志打印出来
     }
     sae_debug($logstr);
     if ($is_debug) {
         sae_set_display_errors(true);
     }
 }
コード例 #3
0
ファイル: Log.php プロジェクト: dlpc/we_three
 /**
  * 针对SAE的日志输出,在日志中心中查看,选择debug选项
  * @param unknown_type $level
  * @param unknown_type $message
  * @param unknown_type $php_error
  */
 public function write_log($level = 'error', $msg, $php_error = FALSE)
 {
     if ($this->_enabled === FALSE) {
         return FALSE;
     }
     $level = strtoupper($level);
     if (!isset($this->_levels[$level]) or $this->_levels[$level] > $this->_threshold) {
         return FALSE;
     }
     if (class_exists('SaeKV')) {
         sae_set_display_errors(false);
         // 关闭信息输出
         sae_debug($level . ': ' . $msg);
         //记录日志
         sae_set_display_errors(true);
         // 记录日志后再打开信息输出,否则会阻止正常的错误信息的显示
         return TRUE;
     } else {
         $filepath = $this->_log_path . 'log-' . date('Y-m-d') . '.php';
         $message = '';
         if (!file_exists($filepath)) {
             $message .= "<" . "?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?" . ">\n\n";
         }
         if (!($fp = @fopen($filepath, FOPEN_WRITE_CREATE))) {
             return FALSE;
         }
         $message .= $level . ' ' . ($level == 'INFO' ? ' -' : '-') . ' ' . date($this->_date_fmt) . ' --> ' . $msg . "\n";
         flock($fp, LOCK_EX);
         fwrite($fp, $message);
         flock($fp, LOCK_UN);
         fclose($fp);
         @chmod($filepath, FILE_WRITE_MODE);
         return TRUE;
     }
 }
コード例 #4
0
ファイル: SaeLogger.php プロジェクト: mitv1c/XssRat
 public function fatal($message)
 {
     $level = "FATAL";
     $log_msg = "[" . $this->p_name . "]\t" . $level . "\t" . $message;
     sae_set_display_errors(false);
     sae_debug($log_msg);
     sae_set_display_errors(true);
 }
コード例 #5
0
ファイル: index.php プロジェクト: RonanHobb/CakePHP-on-SAE
/**
 * Index
 *
 * The Front Controller for handling every request
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.webroot
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
function sae_log($msg)
{
    sae_set_display_errors(false);
    //关闭信息输出
    sae_debug($msg);
    //记录日志
    sae_set_display_errors(true);
    //记录日志后再打开信息输出,否则会阻止正常的错误信息的显示
}
コード例 #6
0
ファイル: sae.php プロジェクト: daolei/grw
 /**
  * 构造函数
  * @param dbConfig  数据库配置
  */
 public function __construct($dbConfig)
 {
     if (TRUE == SP_DEBUG) {
         sae_set_display_errors(TRUE);
     }
     $this->conn = new SaeMysql();
     if ($this->conn->errno()) {
         spError("数据库链接错误 : " . $this->conn->error());
     }
     $this->conn->setCharset("UTF8");
 }
コード例 #7
0
ファイル: audio.php プロジェクト: acsiiii/leeeframework
 function writelog_debug($msg)
 {
     sae_set_display_errors(false);
     //关闭信息输出
     if (is_array($msg)) {
         $msg = implode(",", $msg);
     }
     sae_debug("[abcabc]" . $msg);
     //记录日志
     sae_set_display_errors(true);
     //记录日志后再打开信息输出,否则会阻止正常的错误信息的显示
 }
コード例 #8
0
ファイル: SaeLog.php プロジェクト: jackycgq/bzfshop
 public function outputLog()
 {
     if (empty($this->logArray)) {
         return;
     }
     sae_set_display_errors(false);
     //关闭网页输出
     foreach ($this->logArray as $logItem) {
         // 采用 sae_debug 输出日志
         sae_debug('[' . $logItem['level'] . '][' . $logItem['source'] . '][' . trim($logItem['msg']) . ']');
     }
 }
コード例 #9
0
 protected function write(array $record)
 {
     if (null === $this->stream) {
         if (!$this->url) {
             throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
         }
         $this->errorMessage = null;
         set_error_handler(array($this, 'customErrorHandler'));
         sae_set_display_errors(false);
         //关闭信息输出
         sae_debug((string) $record['formatted']);
         //记录日志
         sae_set_display_errors(true);
         restore_error_handler();
     }
 }
コード例 #10
0
ファイル: function.php プロジェクト: Jitlee/CKY
function ImpoLogger($log_content)
{
    if (isset($_SERVER['HTTP_APPNAME'])) {
        //SAE
        sae_set_display_errors(false);
        sae_debug($log_content);
        sae_set_display_errors(true);
    } else {
        //LOCAL
        $max_size = 500000;
        $log_filename = './log/impo/' . date('Y-m-d') . 'impolog.xml';
        if (file_exists($log_filename) and abs(filesize($log_filename)) > $max_size) {
            unlink($log_filename);
        }
        file_put_contents($log_filename, date('Y-m-d H:i:s') . $log_content . "\n", FILE_APPEND);
    }
}
コード例 #11
0
ファイル: Sae.class.php プロジェクト: yangyadong/CarMarket
 /**
  * 日志写入接口
  * @access public
  * @param string $log 日志信息
  * @param string $destination 写入目标
  * @return void
  */
 public function write($log, $destination = '')
 {
     static $is_debug = null;
     $now = date($this->config['log_time_format']);
     $logstr = "[{$now}] " . $_SERVER['REMOTE_ADDR'] . ' ' . $_SERVER['REQUEST_URI'] . "\r\n{$log}\r\n";
     if (is_null($is_debug)) {
         preg_replace('@(\\w+)\\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
         $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
     }
     if ($is_debug) {
         sae_set_display_errors(false);
     }
     //记录日志不将日志打印出来
     sae_debug($logstr);
     if ($is_debug) {
         sae_set_display_errors(true);
     }
 }
コード例 #12
0
ファイル: Log.php プロジェクト: kokororin/Kotori.php
 /**
  * Write Log File
  *
  * Support Sina App Engine
  *
  * @param string $msg Message
  * @param string $level Log level
  * @return void
  */
 protected static function write($msg, $level = '')
 {
     if (Config::getSoul()->APP_DEBUG == false) {
         return;
     }
     if (function_exists('saeAutoLoader')) {
         $msg = "[{$level}]" . $msg;
         sae_set_display_errors(false);
         sae_debug(trim($msg));
         sae_set_display_errors(true);
     } else {
         $msg = date('[ Y-m-d H:i:s ]') . "[{$level}]" . $msg . "\r\n";
         $logPath = Config::getSoul()->APP_FULL_PATH . '/logs';
         if (!file_exists($logPath)) {
             Helper::mkdirs($logPath);
         }
         file_put_contents($logPath . '/' . date('Ymd') . '.log', $msg, FILE_APPEND);
     }
 }
コード例 #13
0
ファイル: log.class.php プロジェクト: phpdn/xiunophp
 public static function real_write($s, $file = 'phperror.php')
 {
     if (IN_SAE) {
         sae_set_display_errors(false);
         sae_debug($s);
         return TRUE;
     }
     $logpath = FRAMEWORK_LOG_PATH;
     $logfile = $logpath . $file;
     try {
         $fp = fopen($logfile, 'ab+');
         if (!$fp) {
             throw new Exception('写入日志失败,可能磁盘已满,或者文件' . $logfile . '不可写。');
         }
         fwrite($fp, $s);
         fclose($fp);
     } catch (Exception $e) {
     }
     return TRUE;
 }
コード例 #14
0
ファイル: data.php プロジェクト: devsnippet/WeChat-2
function logger2($log_content)
{
    if (isset($_SERVER['HTTP_BAE_ENV_APPID'])) {
        //BAE
        require_once "BaeLog.class.php";
        $logger = BaeLog::getInstance();
        $logger->logDebug($log_content);
    } else {
        if (isset($_SERVER['HTTP_APPNAME'])) {
            //SAE
            sae_set_display_errors(false);
            sae_debug($log_content);
            sae_set_display_errors(true);
        } else {
            $max_size = 100000;
            $log_filename = "log.xml";
            if (file_exists($log_filename) and abs(filesize($log_filename)) > $max_size) {
                unlink($log_filename);
            }
            file_put_contents($log_filename, date('H:i:s') . " " . $log_content . "\r\n", FILE_APPEND);
        }
    }
}
コード例 #15
0
 static function sae_set_display_errors($bool)
 {
     static $is_debug = null;
     if (is_null($is_debug)) {
         preg_replace('@(\\w+)\\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
         $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
     }
     if ($is_debug) {
         sae_set_display_errors($bool);
     }
 }
コード例 #16
0
ファイル: sae.php プロジェクト: szwork2013/distribution
function log_write($log)
{
    static $is_debug = null;
    if (is_null($is_debug)) {
        preg_replace('@(\\w+)\\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
        $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;
    }
    if ($is_debug) {
        sae_set_display_errors(false);
    }
    //记录日志不将日志打印出来
    sae_debug($log);
    if ($is_debug) {
        sae_set_display_errors(true);
    }
}
コード例 #17
0
ファイル: index.php プロジェクト: AbbeyFirst/AbbeyGit
 private function logger($log_content)
 {
     if (isset($_SERVER['HTTP_APPNAME'])) {
         //SAE
         sae_set_display_errors(false);
         sae_debug($log_content);
         sae_set_display_errors(true);
     } else {
         if ($_SERVER['REMOTE_ADDR'] != "127.0.0.1") {
             //LOCAL
             $max_size = 10000;
             $log_filename = "log.xml";
             if (file_exists($log_filename) and abs(filesize($log_filename)) > $max_size) {
                 unlink($log_filename);
             }
             file_put_contents($log_filename, date('H:i:s') . " " . $log_content . "\r\n", FILE_APPEND);
         }
     }
 }
コード例 #18
0
ファイル: sae_functions.php プロジェクト: ysking/commlib
    {
        return false;
    }
}
if (!in_array("saekv", stream_get_wrappers())) {
    stream_wrapper_register("saekv", "SaeKVWrapper");
}
/* END *********************  KVDB Wrapper By Elmer Zhang At 12/Dec/2011 12:37 ****************/
/* START *********************  Supported for AppCookie By Elmer Zhang At 13/Jun/2010 15:49 ****************/
$appSettings = array();
if (isset($_SERVER['HTTP_APPCOOKIE']) && $_SERVER['HTTP_APPCOOKIE']) {
    $appCookie = trim($_SERVER['HTTP_APPCOOKIE']);
    $tmpSettings = array_filter(explode(';', $appCookie));
    if ($tmpSettings) {
        foreach ($tmpSettings as $setting) {
            $tmp = explode('=', $setting);
            $appSettings[$tmp[0]] = $tmp[1];
        }
    }
}
if (isset($appSettings['xhprof']) && in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['xhprof']))) {
    sae_xhprof_start();
    register_shutdown_function("sae_xhprof_end");
}
if (isset($appSettings['debug']) && in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug']))) {
    sae_set_display_errors(true);
}
unset($appSettings);
unset($appCookie);
unset($tmpSettings);
unset($tmp);
コード例 #19
0
ファイル: Kotori.php プロジェクト: changlor/Kotori.php
 /**
  * Write Log File
  *
  * Support Sina App Engine
  *
  * @param string $msg Message
  * @param string $level Log level
  * @return void
  */
 private static function write($msg, $level = '')
 {
     if (Kotori_Config::getInstance()->get('APP_DEBUG') == false) {
         return;
     }
     if (function_exists('saeAutoLoader')) {
         $msg = "[{$level}]" . $msg;
         sae_set_display_errors(false);
         sae_debug(trim($msg));
         sae_set_display_errors(true);
     } else {
         $msg = date('[ Y-m-d H:i:s ]') . "[{$level}]" . $msg . "\r\n";
         $logPath = Kotori_Config::getInstance()->get('APP_FULL_PATH') . '/Log/' . date('Ymd') . '.log';
         file_put_contents($logPath, $msg, FILE_APPEND);
     }
 }
コード例 #20
0
ファイル: SinglePHP.class.php プロジェクト: NONFish/SinglePHP
 /**
  * 打日志,支持SAE环境
  * @param string $msg 日志内容
  * @param string $level 日志等级
  * @param bool $wf 是否为错误日志
  */
 public static function write($msg, $level = 'DEBUG', $wf = false)
 {
     if (function_exists('sae_debug')) {
         //如果是SAE,则使用sae_debug函数打日志
         $msg = "[{$level}]" . $msg;
         sae_set_display_errors(false);
         sae_debug(trim($msg));
         sae_set_display_errors(true);
     } else {
         $msg = date('[ Y-m-d H:i:s ]') . "[{$level}]" . $msg . "\r\n";
         $logPath = C('APP_FULL_PATH') . '/Log/' . date('Ymd') . '.log';
         if ($wf) {
             $logPath .= '.wf';
         }
         file_put_contents($logPath, $msg, FILE_APPEND);
     }
 }
コード例 #21
0
ファイル: cssjs.php プロジェクト: wait121000/discuz3.0forsae
<?php

/**
 *      rewrite输出缓存的css与js内容
 *
 *      2011-6-24 18:28:25 ZouQilong $
 */
sae_set_display_errors(false);
require_once './config/config_global.php';
if (empty($_REQUEST['type'])) {
    $_REQUEST['type'] = 'css';
}
$sae_cache_filename = $_REQUEST['file'] . '.' . $_REQUEST['type'];
$file_content = @file_get_contents("saekv://data/cache/{$sae_cache_filename}");
if ($_REQUEST['type'] == 'css') {
    header('Content-Type:text/css');
}
if ($_REQUEST['type'] == 'js') {
    header('Content-Type:application/javascript');
}
echo "/* {$sae_cache_filename} */\r\n";
//".var_export($_REQUEST,true)."
if ($file_content !== false) {
    echo "/* From saekv */\r\n";
    echo $file_content;
    exit;
} else {
    define('APPTYPEID', 2);
    define('CURSCRIPT', 'forum');
    define('CURMODULE', 'index');
    require './source/class/class_core.php';
コード例 #22
0
function logger($log_content)
{
    if (isset($_SERVER['HTTP_APPNAME'])) {
        // SAE
        //echo "89898989";
        sae_set_display_errors(false);
        sae_debug($log_content);
        sae_set_display_errors(true);
    } else {
        // LOCAL
        $max_size = 500000;
        $log_filename = "log.xml";
        if (file_exists($log_filename) and abs(filesize($log_filename)) > $max_size) {
            unlink($log_filename);
        }
        file_put_contents($log_filename, date('Y-m-d H:i:s') . $log_content . "\r\n", FILE_APPEND);
    }
}