• <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 楊粼波 閱讀(470) 評論(0)  編輯 收藏 引用

            久久综合狠狠综合久久| 色综合久久久久综合体桃花网| 无码久久精品国产亚洲Av影片| 久久精品国产男包| 中文成人无码精品久久久不卡 | 精品久久久久久国产| 日韩一区二区三区视频久久| 国产三级精品久久| 欧美与黑人午夜性猛交久久久 | 久久只这里是精品66| 亚洲人成无码www久久久| 无码任你躁久久久久久| 99久久综合国产精品免费| 国产精品99久久久精品无码 | 成人久久免费网站| 久久永久免费人妻精品下载| 97热久久免费频精品99| 久久精品国产一区| 久久亚洲国产成人精品无码区| 亚洲欧美日韩精品久久亚洲区 | 久久无码国产专区精品| 男女久久久国产一区二区三区| 99久久成人国产精品免费| 久久久久久久久久久免费精品| 日韩精品久久久久久久电影| 久久亚洲欧美国产精品| 国产综合精品久久亚洲| 亚洲国产精品成人AV无码久久综合影院| 久久天天躁夜夜躁狠狠| 久久精品国产亚洲精品2020| 色综合久久最新中文字幕| 中文字幕无码久久人妻| 久久99国产精品久久99果冻传媒 | 少妇久久久久久久久久| 久久综合狠狠综合久久激情 | 久久无码国产| 91精品国产综合久久久久久| 模特私拍国产精品久久| 成人精品一区二区久久| 色妞色综合久久夜夜| 亚洲国产成人久久一区WWW|