PHP implementation log processing class Library _php tutorial

Source: Internet
Author: User
following the previous articleOne of the technical notes of the "developed micro-e-commerce website" , yesterday did the function of log processing.

for today's applications, the importance of logging is self-evident. It is hard to imagine an application that does not have any logging capabilities running in a production environment. Logs can provide a variety of functions, including the recording program run-time error messages, status information, debugging information and execution time information. In a production environment, logging is an important basis for finding the source of the problem. The various information that is generated when the application is run should be logged through the Log class library .

don't say much nonsense, attach the source code of the Log class library:

             < span>   = < span>   = < span>  = < span>  = < span>  = < span>  = ' Log_ '           __construct () {< span>  ->log_file_path =  ->log_switch =  ->log_max_len =              (!self::Self::=  Self::       record (THING log)/1-Error (err log)           (,, (-  (Self::== =->log_file_pre.-Self::=(->log_file_path., ' a '  ( 0: (Self::, ' THING LOG: '. ' ' .. ' ' ..(13  1: (Self::, ' ERROR LOG: '. ' ' .. ' ' ..(13  : (Self::, ' THING LOG: '. ' ' .. ' ' ..(13                = ((- (=(- ((=()) != (! = '. ' &&!= '..' ((->log_file_path.) = = ' file ' =('_', (<[1 =[1      (== = 0  < span> ((->log_file_path.->log_file_pre.) &&(->log_file_path.->log_file_pre.) >=- =() + 1        0             (Self:: }
                              

Function Description:
This log class uses a singleton mode to conserve resources. The file size is determined by itself, and the file is created by itself in order to exceed the specified size. For example, if the file log_0 is larger than the specified size, re-create the log_1 file (Note: Create the file is the number of the installation file name suffix, do not change the log file name arbitrarily).

needs to be optimized: There is no maximum number of specified files, so you should manually delete too many log files at regular intervals.

Invocation Example:

< span="">< span="">< span="">< span="">< span="">< span="">::< span="">< span="">< span="">< span="">< span="">< < span="">/c22>< span="">< span="">< span="">< span="">   < span=""> (' y-n-j  h:m:s ' < span=""> < span="">  < span="">  ->close (); < span="">

Thank you for your review!

Article Source: http://www.ihuxu.com/p/223.html

Public number (daily sharing of valuable Internet Information): Hu Xu Personal Blog

Sina Weibo: @ Around the Internet

Programming discussion groups: 235173087

qq:2252065614

< p>

< p="">

< strong="">

http://www.bkjia.com/PHPjc/732360.html www.bkjia.com true http://www.bkjia.com/PHPjc/732360.html techarticle One of the technical notes of the "development of the micro-electronic Commerce website" in the previous article, yesterday did the function of log processing. For today's applications, the importance of logging is self-evident. ...

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