1. Go to this page and download the library: Download spacetab-io/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/ */
spacetab-io / logger example snippets
use Spacetab\Logger\Logger;
$log = Logger::default(); // Psr\Log\LoggerInterface
$log->info('write something');
use Monolog\Logger;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
class LoggerModule implements ServiceProvider
{
/**
* @param ContainerInterface $container
*/
public function provideServices($container): void
{
$container->register(LoggerInterface::class, function () {
return Logger::default(); // it's all!
});
}
}
use Spacetab\Logger\Logger;
use Psr\Log\LogLevel;
$log = new Logger('ChannelName', LogLevel::DEBUG); // enabled debug mode and set the channel name
$log->addStreamHandler();
$log->register();
$log->getMonolog()->info('Hello world');
use Spacetab\Logger\Logger;
use Monolog\Handler\HandlerInterface;
use Monolog\Handler\NullHandler;
use Psr\Log\LogLevel;
$log = new Logger('ChannelName', LogLevel::DEBUG); // enabled debug mode and set the channel name
$log->addStreamHandler();
$log->addHandler(function (string $level): HandlerInterface {
return new NullHandler($level);
});
$log->register();
$log->getMonolog()->info('Diligence is the mother of success');
bash
[2019-04-29 21:39:52] Server.INFO: CONFIG_PATH = ./configuration
[2019-04-29 21:39:52] Server.INFO: STAGE = local
[2019-04-29 21:39:52] Server.INFO: Configuration module loaded
[2019-04-29 21:39:52] Server.INFO: HTTP static server started at 0.0.0.0:8080
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.