CI source code analysis (II)-Log, Log Module, cilog

Source: Internet
Author: User

CI source code analysis (II)-Log, Log Module, cilog
The Log Module of Ci is implemented and used as a library.
(1) Usage
(A) configure it in applicatin/environment/config. php.

  • Log_threshold: Specifies the value of the log level that can be written. array ('error' => '1', 'debug' => '2', 'info' => '3', 'all' => '4 '). levels smaller than or equal to the threshold value can be written. In combination with this evironment, different levels of logs can be recorded in different environments. For example, the development environment records all levels, the testing records to the debug level, and the production environment records the error level.
  • Log_path: the root directory of the log file. The default value is application/logs. You must ensure that the directory has the write permission.
  • Log_date_format: Date Format in daily logs

(B) There is only one method for calling call logs.
  • $ This-> log-> write_log ($ level = 'error', $ msg)


(2) Implementation Method
(A) library/Log. php
  • Write_log ($ level = 'error', $ msg, $ php_error = FALSE): determines whether logs can be written based on the log level.



(3) advantages and disadvantages
(A) Disadvantages
  • The threshold configuration limits the writing of logs. For example, in the production environment, logs at the error level can only be written, even if you want to temporarily add some debug-level logs. Here I have extended a write_log_force method. Call this method, the threshold is first adjusted to the all level, then write the log, and finally restore the threshold level. Address https://github.com/wkupaochuan/analysis-about-ci-frame.git, in application/library/MY_Log.php



Ci framework source code analysis address https://github.com/wkupaochuan/analysis-about-ci-frame.git

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.