1. Go to this page and download the library: Download corpus/loggers 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/ */
corpus / loggers example snippets
use Corpus\Loggers\LoggerWithContext;
use Corpus\Loggers\LogLevelFilter;
use Corpus\Loggers\MemoryLogger;
use Corpus\Loggers\MultiLogger;
use Corpus\Loggers\StreamResourceLogger;
use Psr\Log\LogLevel;
xt([ 'Logger' => 'Number 1' ]),
[ Psr\Log\LogLevel::INFO ]
),
new LogLevelFilter(
(new LoggerWithContext($cliLogger))->withContext([ 'Logger' => 'Number 2' ]),
[ Psr\Log\LogLevel::INFO, LogLevel::DEBUG ]
),
new LogLevelFilter(
(new LoggerWithContext($cliLogger))->withContext([ 'Logger' => 'Number 3' ]),
[ Psr\Log\LogLevel::INFO, LogLevel::DEBUG ],
true // reverse filter - only log levels NOT in the array
)
);
$logger->info('Hello World', [ 'hello' => 'world' ]);
$logger->debug('How are you?', [ 'foo' => 'bar' ]);
$logger->error('I am fine', [ 'bar' => 'baz', 'baz' => 'qux' ]);
echo "\n--- dumping memory logger ---\n\n";
var_export($memoryLogger->getLogs());
function withContext(array $context) : self
function withAddedContext(array $context) : self
function withAdditionalLoggers(\Psr\Log\LoggerInterface ...$loggers) : self
function withAdditionalLoggers(\Psr\Log\LoggerInterface ...$loggers) : self
function withContext(array $context) : self
function withAddedContext(array $context) : self
function __construct(\Psr\Log\LoggerInterface $logger [, int $verbosity = 0 [, ?callable $verbosityFromLevelCallback = null]])
function withVerbosity(int $verbosity) : self
function withVerbosityFromLevelCallback(callable $verbosityFromLevelCallback) : self
function __construct(\Psr\Log\LoggerInterface $logger [, array $context = []])
function withContext(array $context) : self
function withAddedContext(array $context) : self
function __construct(\Psr\Log\LoggerInterface $logger, array $levels [, bool $exclude = false])