• <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)  編輯 收藏 引用

            国产精品成人99久久久久 | 国色天香久久久久久久小说 | 久久久久人妻一区精品性色av| 亚洲AV无码久久精品蜜桃| 国内精品久久人妻互换| 国内精品久久久久久麻豆| 久久亚洲精品无码aⅴ大香| 91精品国产91久久久久福利| 午夜精品久久久久久久无码| 精品久久久久久无码中文字幕一区| AAA级久久久精品无码区| 久久综合九色综合精品| 日韩AV毛片精品久久久| 欧美成人免费观看久久| 久久久一本精品99久久精品88| 日韩精品久久久久久免费| 久久亚洲精品无码AV红樱桃| 中文成人无码精品久久久不卡| 久久人人爽人人爽人人片AV东京热 | 丁香狠狠色婷婷久久综合| 91超碰碰碰碰久久久久久综合| 久久精品国产黑森林| 久久午夜福利无码1000合集| 久久人人妻人人爽人人爽| 亚洲午夜精品久久久久久人妖| 伊人久久国产免费观看视频| 色欲久久久天天天综合网精品| 久久精品一区二区| 久久亚洲国产精品123区| 久久久久波多野结衣高潮| 国产精品视频久久久| 亚洲午夜福利精品久久| 国产精品一区二区久久不卡 | 久久综合综合久久狠狠狠97色88| 久久国产精品免费| 久久久久久久亚洲Av无码| 久久99国产精品成人欧美| 无码精品久久久久久人妻中字| 久久精品无码av| 国产韩国精品一区二区三区久久| 亚洲国产成人久久综合碰|