The log module of CI is implemented and used as a library.
(a) How to use
(a) configuration in applicatin/environment/config/config.php
- Log_threshold: Writable log level thresholds. Array (' ERROR ' = ' 1 ', ' DEBUG ' = ' 2 ', ' INFO ' = ' 3 ', ' all ' = ' 4 '). Levels that are less than or equal to the threshold can be written. With this evironment, different levels of logging can be recorded in different environments, such as development environment record all level, testing logging to debug level, production environment record error level
- Log_path: Log file root directory, default is Application/logs, must ensure that directory has write permission
- Log_date_format: Date format in daily log
(b) There is only one way to invoke the call log
- $this->log->write_log ($level = ' error ', $msg)
(ii) Modalities of implementation
(a) library/log.php
- Write_log ($level = ' error ', $msg, $php _error = FALSE): Determines whether the log can be written according to the log level
(iii) Advantages and disadvantages
(a) shortcomings
- The threshold configuration restricts the writing of dead logs, such as in the production environment, and can only write to the error level log, even if you want to temporarily add some debug-level log. Here I have expanded a Write_log_force method myself. Calling this method, the threshold is first tuned to the all level, then the log is written, and the threshold level is finally restored. Address Https://github.com/wkupaochuan/analysis-about-ci-frame.git, in application/library/my_log.php
CI Framework Source Analysis Address Https://github.com/wkupaochuan/analysis-about-ci-frame.git
CI Source (a)-log, log