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