PHP implementation of the log processing class library _ PHP Tutorial

Source: Internet
Author: User
PHP implements the log processing class library. Following one of the technical notes in the previous article [the development of the micro-e-commerce website], the log processing function was implemented yesterday. For today's applications, the importance of logs is self-evident. Following one of the technical notes in the previous article [the development of the micro-e-commerce website], the log processing function was implemented yesterday.

For today's applications, the importance of logs is self-evident. It is hard to imagine that applications without any logging function are running in the production environment. Logs provide a variety of functions, including recording the error information, status information, debugging information, and execution time information generated when the program is running. In the production environment, logs are an important basis for finding the source of the problem. All information generated when the application is running should be recorded through the log class library.

The source code of the log class library is attached:

====== 'Log _ '_ construct () {-> log_file_path =-> log_switch =-> log_max_len = (! Self: self ::= self: Record (thing log)/1-> error 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 (-> log_file_path. -> log_file_pre .) & (-> log_file_path. -> log_file_pre.)> =-> = () + 1 0 (self ::}

Function description:
This log class uses the Singleton mode to save resources. Determine the file size by yourself. if the file size exceeds the specified size, create the file in sequence. For example, if the file log_0 is greater than the specified size, re-create the log_1 File (note: The file is created with a number with a suffix of the file name. do not change the log file name at will ).

To be optimized:The maximum number of files is not specified, so you need to manually delete too many log files on a regular basis.

Call example:

=:-> (1, 'log description', ('Y-n-j H: m: S'-> close ();

Thank you for your reference!

< strong>

Programming Group: 235173087

QQ: 2252065614

< p>

One of the technical notes for the development of the micro-e-commerce website, the log processing function was implemented yesterday. For today's applications, the importance of logs 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.