PHP code example of effectra / log

1. Go to this page and download the library: Download effectra/log library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

effectra / log example snippets


   use Effectra\Log\Logger;

   $logger = new Logger('/path/to/log/file.log');
   

   $logger->info('This is an informational message.');
   $logger->error('An error occurred.', ['context' => 'additional data']);
   // ...
   

   use Effectra\Log\LogLevel;

   $logger->log(LogLevel::DEBUG, 'Debug message');
   $logger->log(LogLevel::WARNING, 'Warning message');
   // ...
   

   use Effectra\Log\LoggerAware;
   use Psr\Log\LoggerInterface;

   class MyClass implements LoggerAware
   {
       public function __construct(LoggerInterface $logger)
       {
           $this->setLogger($logger);
       }

       // ...
   }