2021-02-11 617次浏览

First verisons of yiisoft/log and some of the drivers called "targets" were released.

Log is PSR-3 compatible so using it in your apps is easy:

final class MyClass
{
    private \Psr\Log\LoggerInterface $logger;

    public function __construct(\Psr\Log\LoggerInterface $logger)
    {
    	$this->logger = $logger;
    }

    public function doIt(): void
    {
	    $this->logger->info('Doing it!');
    
        // ...
    }
}

The strength of the library is in its convenient configuration. You are always logging via the same logger instance but can route log messages to different targets. Each target processes messages differently. It may write it to a file, send it to syslog, email it or send it to another PSR-3 compatible logger.

Details could be found in the package readme.

Along with the main log package, the file and syslog targets were released.