• <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>

            牽著老婆滿街逛

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

            一個(gè)簡(jiǎn)單php日志類

            轉(zhuǎn)載自:http://blog.csdn.net/lxzo123/article/details/6371233

            日志類如下,news目錄為當(dāng)前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/');
            }
            //數(shù)據(jù)庫(kù)設(shè)定
            $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 楊粼波 閱讀(470) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            伊人色综合久久天天网| 美女写真久久影院| 久久亚洲欧美日本精品| 久久国产精品无| 亚洲乱亚洲乱淫久久| 久久久久久久久久久| 亚洲午夜久久久精品影院 | 一本久久a久久精品综合夜夜| 天天综合久久一二三区| 久久国产免费观看精品| 熟妇人妻久久中文字幕| 久久久中文字幕日本| 久久亚洲国产午夜精品理论片| 99久久无色码中文字幕人妻 | 久久精品国产99国产电影网| 久久天天躁夜夜躁狠狠躁2022 | 亚洲七七久久精品中文国产| 日本精品久久久久中文字幕8| 久久精品国产亚洲av麻豆小说| 欧美日韩精品久久久免费观看| 狠狠人妻久久久久久综合蜜桃| 91精品国产综合久久精品| 中文字幕日本人妻久久久免费| 久久91精品国产91久| 亚洲精品99久久久久中文字幕| 久久久久久亚洲精品不卡 | 久久精品成人欧美大片| 人人狠狠综合88综合久久| 久久精品国产一区二区| 国产精品无码久久四虎| 国产香蕉97碰碰久久人人| 99久久www免费人成精品| 久久青青草原国产精品免费| 成人久久精品一区二区三区| 99久久综合狠狠综合久久止| 久久精品嫩草影院| 久久精品一区二区国产| 国产一区二区精品久久岳| 精品久久人人做人人爽综合 | 国产成人精品久久| 久久亚洲美女精品国产精品|