PHP code example of jdwx / log

1. Go to this page and download the library: Download jdwx/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/ */

    

jdwx / log example snippets


$logger = new \JDWX\Log\StderrLogger();
$logger->info( 'Hello, world!' );

class MyClass implements \Psr\Log\LoggerInterface {
    use \JDWX\Log\RelayLoggerTrait;

    public function log( int $level, Stringable|string $message, 
                         array $context = [] ) : void {
        echo "Log message: {$message}\n";
    }

}

$x = new MyClass();
$x->info( 'Hello, world!' );