PHP Common Library

Source: Internet
Author: User
Tags php error php error log

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

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.