Suddenly rise, want to summarize the PHP used library, of course, is 1.1 points increase, not all of a sudden complete oh ~
First, PHP log class library Monolog
Powerful, you can send logs to files, sockets, mailboxes, databases, and various Web services.
Strong replaceable ability.
Extensibility and customization is convenient.
Thinking:
If let me design, I will consider providing to the user,
1. Log object that can be manipulated directly.
2, the input stream object, Xxxhandler object, between the log object and the output media abstraction layer out. Log Object-----> streamhandler-----> actual xxx.txt document because the output media may be txt document, MySQL database, mail, socket send, etc.
Streamhandler writes to the disk, Mailhandler writes to the message, in Monolog, the Xxxhandler object is stacked, pipelining, that is, from top to bottom, first processing Mailhandler decides whether the message is issued by the log, when it is finished, Determines whether the following processing is paused, if
If you continue, go to Streamhandler to write to disk ... this stack-up, linear pipelining solution is great.
3, Monolog inside is used, the Observer mode , the log object to inject multiple listening xxxhandler.
Log Object---(Viewer mode)------>xxxhandler--------> Output Media
4, but, if it is me, build an abstract class handler, put the concrete pattern in the handler class implementation, the log object operation Hanlder inside the method, the method implementation with specific Streamhandler or Mailhandler, but so It is not a pipelined execution from top to bottom. In the
It's better to do this in just one time.
Streamhandler: Writes the record in the PHP stream, mainly for the log file. Sysloghandler: Write the records into the syslog. Errorloghandler: Write the record in the PHP error log. nativemailerhandler: Send log records using the mail () function of PHP. Sockethandler: Write the log through the socket. Amqphandler: Write the records into a service that is compatible with the AMQP protocol. browserconsolehandler: Writes log records to the browser's console. Because you are using the browser's console object, you need to see if the browser supports it. Redishandler: Write the records into Redis. Mongodbhandler: Write the records into the MONGO. Elasticsearchhandler: Write the records to the Elasticsearch service. Bufferhandler: Allows us to cache the log records for processing at once.
RELATED links:
http://segmentfault.com/a/1190000002775923//monolog Class Library detailed
PHP Common Library