Ignore:
Timestamp:
2012/03/14 21:36:17 (12 years ago)
Author:
Seasoft
Message:

#1676 (ログファイルを分離する)

  • 管理機能「システム設定>EC-CUBE ログ表示」画面
Location:
branches/version-2_12-dev/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/Smarty/templates/admin/system/log.tpl

    r20764 r21647  
    2323*}--> 
    2424 
    25 <p>直近の<!--{$line_max}-->行</p> 
     25<style type="text/css"> 
     26    th { 
     27        width: auto; 
     28    } 
     29</style> 
     30 
     31<!--{if count($arrErr) >= 1}--> 
     32    <div class="attention"> 
     33        <!--{foreach from=$arrErr item=err}--> 
     34            <!--{$err}--> 
     35        <!--{/foreach}--> 
     36    </div> 
     37<!--{/if}--> 
     38 
     39<form action="?" name="form1" style="margin-bottom: 1ex;"> 
     40    <!--{assign var=key value="log"}--> 
     41    <select name="<!--{$key|h}-->" style="<!--{$arrErr[$key]|sfGetErrorColor}-->"> 
     42        <!--{html_options options=$arrLogList selected=$arrForm[$key]}--> 
     43    </select> 
     44    <!--{assign var=key value="line_max"}--> 
     45    直近の<input type="text" name="<!--{$key|h}-->" value="<!--{$arrForm[$key].value|h}-->" size="6" maxlength="<!--{$arrForm[$key].length|h}-->" style="<!--{$arrErr[$key]|sfGetErrorColor}-->" />行 
     46    <a class="btn-normal" href="javascript:;" onclick="form1.submit(); return false;"><span>読み込む</span></a> 
     47</form> 
     48 
    2649<table class="list log"> 
    2750    <tr> 
  • branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Log.php

    r21591 r21647  
    3434class LC_Page_Admin_System_Log extends LC_Page_Admin_Ex { 
    3535 
    36     // }}} 
    37     // {{{ functions 
     36    var $arrLogList = array(); 
    3837 
    3938    /** 
     
    7877 
    7978        // POST値をセット 
    80         $objFormParam->setParam($_POST); 
    81  
    82         if (SC_Utils_Ex::sfIsInt($tmp = $objFormParam->getValue('line'))) { 
    83             $this->line_max = $tmp; 
    84         } 
    85  
    86         $this->tpl_ec_log = $this->getEccubeLog(); 
     79        $objFormParam->setParam($_REQUEST); 
     80        $this->arrErr = $objFormParam->checkError(); 
     81        $this->arrForm = $objFormParam->getFormParamList(); 
     82 
     83        $this->loadLogList(); 
     84 
     85        if (empty($this->arrErr)) { 
     86            $this->line_max = $objFormParam->getValue('line_max'); 
     87 
     88            $log_path = $this->getLogPath($objFormParam->getValue('log')); 
     89            $this->tpl_ec_log = $this->getEccubeLog($log_path); 
     90        } 
    8791 
    8892        // フックポイント. 
     
    103107     * パラメーターの初期化. 
    104108     * 
    105      * @return object SC_FormParam インスタンス 
    106109     * @return void 
    107110     */ 
    108111    function lfInitParam(&$objFormParam) { 
    109         $objFormParam->addParam('line_max', 'line_max', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK')); 
     112        $objFormParam->addParam('ファイル', 'log', null, '', array()); 
     113        $objFormParam->addParam('行数', 'line_max', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), 50); 
    110114    } 
    111115 
     
    115119     * @return array $arrLogs 取得したログ 
    116120     */ 
    117     function getEccubeLog() { 
     121    function getEccubeLog($log_path_base) { 
    118122 
    119123        $index = 0; 
    120124        $arrLogs = array(); 
    121125        for ($gen = 0 ; $gen <= MAX_LOG_QUANTITY; $gen++) { 
    122             $path = LOG_REALFILE; 
     126            $path = $log_path_base; 
    123127            if ($gen != 0) { 
    124128                $path .= ".$gen"; 
     
    132136            $arrBodyReverse = array(); 
    133137            foreach ($arrLogTmp as $line) { 
     138                // 上限に達した場合、処理を抜ける 
     139                if (count($arrLogs) >= $this->line_max) break 2; 
     140 
    134141                $line = chop($line); 
    135142                if (preg_match('/^(\d+\/\d+\/\d+ \d+:\d+:\d+) \[([^\]]+)\] (.*)$/', $line, $arrMatch)) { 
     
    145152 
    146153                    $arrLogs[] = $arrLogLine; 
    147  
    148                     // 上限に達した場合、処理を抜ける 
    149                     if (count($arrLogs) >= $this->line_max) break 2; 
    150154                } else { 
    151155                    // 内容 
     
    156160        return $arrLogs; 
    157161    } 
     162 
     163    /** 
     164     * ログファイルのパスを取得する 
     165     * 
     166     * セキュリティ面をカバーする役割もある。 
     167     */ 
     168    function getLogPath($log_name) { 
     169        if (strlen($log_name) === 0) { 
     170            return LOG_REALFILE; 
     171        } 
     172        if (defined($const_name = $log_name . '_LOG_REALFILE')) { 
     173            return constant($const_name); 
     174        } 
     175        trigger_error('不正なログが指定されました。', E_USER_ERROR); 
     176    } 
     177 
     178    /** 
     179     * ログファイルの一覧を読み込む 
     180     * 
     181     * TODO mtb_constants から動的生成したい。 
     182     * @return void 
     183     */ 
     184    function loadLogList() { 
     185        $this->arrLogList[''] = '標準ログファイル'; 
     186        $this->arrLogList['CUSTOMER'] = '会員ログイン ログファイル'; 
     187        $this->arrLogList['ADMIN'] = '管理機能ログファイル'; 
     188 
     189        if (defined('DEBUG_LOG_REALFILE') && strlen(DEBUG_LOG_REALFILE) >= 1) { 
     190            $this->arrLogList['DEBUG'] = 'デバッグログファイル'; 
     191        } 
     192 
     193        if (defined('ERROR_LOG_REALFILE') && strlen(ERROR_LOG_REALFILE) >= 1) { 
     194            $this->arrLogList['ERROR'] = 'エラーログファイル'; 
     195        } 
     196 
     197        if (defined('DB_LOG_REALFILE') && strlen(DB_LOG_REALFILE) >= 1) { 
     198            $this->arrLogList['DB'] = 'DBログファイル'; 
     199        } 
     200    } 
    158201} 
Note: See TracChangeset for help on using the changeset viewer.