1. Go to this page and download the library: Download helsingborg-stad/psr-logger 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/ */
helsingborg-stad / psr-logger example snippets
use PsrLogger\LoggerFactory;
use PsrLogger\Loggers\PhpErrorLogger;
use Psr\Log\LogLevel;
$factory = new LoggerFactory(
namespace: 'MyPlugin',
loggers: [['logger' => new PhpErrorLogger(), 'logLevel' => LogLevel::ERROR]]
);
$logger = $factory->createLogger();
$logger->error('Something went wrong');
// → [ERROR]:[MyPlugin]: Something went wrong
$logger->debug('Verbose detail'); // suppressed — below ERROR threshold
$logger->info('Just FYI'); // suppressed — below ERROR threshold