Understanding PHP-FIG: PSR-3 (Logger Interface)

As a learning experience, I create PHP-based CMS using FIG standards. Can someone explain to me how I should integrate PSR-3 into my project. I downloaded the source @ https://github.com/php-fig/log/tree/master/Psr/Log and I think I lost it, how to proceed.

I do not understand what LoggerAwareInterface does. Do I have to modify the above source to actually log the data as I want, or does it work as a wrapper for my own log class. Any help / information would be appreciated.

PS I should note that the best guide I could find was http://phpmaster.com/logging-with-psr-3-to-improve-reusability/ (in particular, the section: Using PSR-3 to prevent freezing) Logger) and he still didn't click on me.

+6
source share
1 answer

Just in case someone searches and finds it, I decided that I should share what I learned.

The answer I came up with is to create a class called Log in your designated namespace. To simplify the task, I just set my class to the extension \ Psr \ Log \ AbstractLogger. Since I did this, I just had to add a method called log with parameters:

$ level, $ message, array $ context = array ()

If you do not want this, simply create a class that has all the methods in AbstractLogger, and then set it to impression \ Psr \ Log \ LoggerInterface

What is it.

+5
source

Source: https://habr.com/ru/post/947367/


All Articles