• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            一個簡單php日志類

            轉載自:http://blog.csdn.net/lxzo123/article/details/6371233

            日志類如下,news目錄為當前php文檔根目錄下子目錄。

            <?php
            if! defined('BASEPATH') ) {
                
            define ('BASEPATH', $_SERVER['DOCUMENT_ROOT'].'/news/');
            }
            require_once BASEPATH.'config/config.inc.php';
            require_once BASEPATH.'config/constants.php';

            define ("LOG_PATH", $config['log']['log_path']);
            define ("LOG_DATE_FORMAT", $config['log']['log_date_format']);

            /**
             * Logging Class
             * @subpackage    Libraries
             * @category    Logging
             * @link        
             
            */
             
            class CI_Log {

                
            var $log_path = '../logs/';
                
            var $_threshold    = 4;
                
            var $_date_fmt    = 'Y-m-d H:i:s';
                
            var $_enabled    = TRUE;
                
            var $_levels    = array('ERROR' => '1', 'DEBUG' => '2',  'INFO' => '3', 'ALL' => '4');

                
            /**
                 * Constructor
                 *
                 * @access    public
                 
            */
                
            function CI_Log()
                {
                    
            ifdefined(LOG_PATH) )
                    {
                        
            $this->log_path = LOG_PATH;
                    }
                    
            if ( ! is_dir($this->log_path))
                    {
                        
            $this->_enabled = FALSE;
                    }
                        
                    
            if ( defined(LOG_DATE_FORMAT) )
                    {
                        
            $this->_date_fmt = LOG_DATE_FORMAT;
                    }
                }
                
                
            // --------------------------------------------------------------------
                
                
            /**
                 * Write Log File
                 *
                 * Generally this function will be called using the global log_message() function
                 *
                 * @access    public
                 * @param    string    the error level
                 * @param    string    the error message
                 * @param    bool    whether the error is a native PHP error
                 * @return    bool
                 
            */        
                
            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;
                    }
                    
                    
            $filepath = $this->log_path.'log-'.date('Y-m-d').'.log';
                    
            $message  = '';
                    
                    
            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;
                }

            }
            // END Log Class

            /* End of file Log.php */


            配置文件
            config.inc.php

            <?php
            /**
             * 配置文件
             
            */
            if! defined('BASEPATH') ) {
                
            define ('BASEPATH', $_SERVER['DOCUMENT_ROOT'].'/news/');
            }
            //數據庫設定
            $config['db']=array(
                                                        );                        
            //日志文件目錄
            $config['log']=array(
                                    
            'log_date_format' => 'Y-m-d H:i:s',
                                    
            'log_path' =>  '../logs/'
                                   );
                               
            ?>


            配置文件

            constants.php

            <?php 

            define('FILE_READ_MODE', 0644);
            define('FILE_WRITE_MODE', 0666);
            define('DIR_READ_MODE', 0755);
            define('DIR_WRITE_MODE', 0777);

            /*
            |--------------------------------------------------------------------------
            | File Stream Modes
            |--------------------------------------------------------------------------
            |
            | These modes are used when working with fopen()/popen()
            |
            */

            define('FOPEN_READ',                             'rb');
            define('FOPEN_READ_WRITE',                        'r+b');
            define('FOPEN_WRITE_CREATE_DESTRUCTIVE',         'wb'); // truncates existing file data, use with care
            define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE',     'w+b'); // truncates existing file data, use with care
            define('FOPEN_WRITE_CREATE',                     'ab');
            define('FOPEN_READ_WRITE_CREATE',                 'a+b');
            define('FOPEN_WRITE_CREATE_STRICT',             'xb');
            define('FOPEN_READ_WRITE_CREATE_STRICT',        'x+b');

            /* End of file constants.php */




            posted on 2014-06-10 00:14 楊粼波 閱讀(474) 評論(0)  編輯 收藏 引用

            岛国搬运www久久| 青草影院天堂男人久久| 国产精品久久久香蕉| 亚洲色婷婷综合久久| 97久久精品人妻人人搡人人玩| 久久精品国产影库免费看| 一级做a爰片久久毛片看看| 色综合久久无码中文字幕| 大香网伊人久久综合网2020| 久久久久av无码免费网| 久久精品国产一区二区| 国产午夜免费高清久久影院| 久久伊人色| 青青青伊人色综合久久| 浪潮AV色综合久久天堂| 天堂无码久久综合东京热| 国产精品永久久久久久久久久| 久久久无码人妻精品无码| 伊人久久亚洲综合影院| 久久久久这里只有精品 | 久久亚洲精品无码观看不卡| 久久精品中文騷妇女内射| 伊人色综合久久天天人守人婷| 国产午夜福利精品久久| 久久精品国产亚洲精品2020| 亚洲精品第一综合99久久| 久久一区二区三区99| 欧美精品一区二区久久| 精品久久久无码中文字幕| 久久综合欧美成人| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久亚洲欧洲国产综合| 精品无码久久久久国产动漫3d | 亚洲va久久久噜噜噜久久男同 | 午夜不卡久久精品无码免费| 久久se精品一区二区影院| 色综合久久天天综合| 日本免费久久久久久久网站| 国内精品久久人妻互换| 99精品国产在热久久| 久久免费高清视频|