generated from chicory/php-env
#9 Logger setup
This commit is contained in:
parent
21e254bfbc
commit
8ef5bd0c49
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,3 +10,6 @@ composer.lock
|
|||||||
/var/cache/*
|
/var/cache/*
|
||||||
!/var/cache/.gitkeep
|
!/var/cache/.gitkeep
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
/var/log/*
|
||||||
|
!/var/log/.gitkeep
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
"nyholm/psr7": "^1.8",
|
"nyholm/psr7": "^1.8",
|
||||||
"nyholm/psr7-server": "^1.1",
|
"nyholm/psr7-server": "^1.1",
|
||||||
"guzzlehttp/psr7": "^2",
|
"guzzlehttp/psr7": "^2",
|
||||||
"php-di/slim-bridge": "^3.4"
|
"php-di/slim-bridge": "^3.4",
|
||||||
|
"monolog/monolog": "^3.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpstan/phpstan": "^2.1",
|
"phpstan/phpstan": "^2.1",
|
||||||
|
@ -19,8 +19,8 @@ return $config
|
|||||||
'ternary_to_null_coalescing' => true,
|
'ternary_to_null_coalescing' => true,
|
||||||
'concat_space' => ['spacing' => 'one'],
|
'concat_space' => ['spacing' => 'one'],
|
||||||
])
|
])
|
||||||
->setCacheFile('/app/var/cache/php-cs-fixer.cache')
|
->setCacheFile(__DIR__ . '/../var/cache/php-cs-fixer.cache')
|
||||||
->setFinder(PhpCsFixer\Finder::create()
|
->setFinder(PhpCsFixer\Finder::create()
|
||||||
->in('/app/src')
|
->in(__DIR__ . '/../src')
|
||||||
->in('/app/tests')
|
->in(__DIR__ . '/../tests')
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
bootstrap="../vendor/autoload.php"
|
bootstrap="../vendor/autoload.php"
|
||||||
colors="true"
|
cacheResultFile="../var/cache/phpunit.cache"
|
||||||
|
colors="true"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Application Test Suite">
|
<testsuite name="Application Test Suite">
|
||||||
<directory suffix="Test.php">/app/tests</directory>
|
<directory suffix="Test.php">../tests</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -3,12 +3,22 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use DI\Bridge\Slim\Bridge;
|
use DI\Bridge\Slim\Bridge;
|
||||||
|
use DI\Container;
|
||||||
use DI\ContainerBuilder;
|
use DI\ContainerBuilder;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Slim\App;
|
use Slim\App;
|
||||||
|
|
||||||
return function (): App {
|
return function (): App {
|
||||||
$containerBuilder = new ContainerBuilder();
|
$containerBuilder = new ContainerBuilder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bind dependencies.
|
||||||
|
*
|
||||||
|
* @var callable(ContainerBuilder<Container>):void $dependencies
|
||||||
|
* */
|
||||||
|
$dependencies = require __DIR__ . '/dependencies.php';
|
||||||
|
$dependencies($containerBuilder);
|
||||||
|
|
||||||
$container = $containerBuilder->build();
|
$container = $containerBuilder->build();
|
||||||
|
|
||||||
/** @var App<ContainerInterface> $app */
|
/** @var App<ContainerInterface> $app */
|
||||||
|
23
src/Infrastructure/Boot/dependencies.php
Normal file
23
src/Infrastructure/Boot/dependencies.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use DI\ContainerBuilder;
|
||||||
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
|
use Monolog\Logger;
|
||||||
|
use Monolog\Processor\UidProcessor;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
return function (ContainerBuilder $builder): void {
|
||||||
|
$builder->addDefinitions([
|
||||||
|
LoggerInterface::class => function (ContainerInterface $container) {
|
||||||
|
$logger = new Logger('app');
|
||||||
|
|
||||||
|
$logger->pushProcessor(new UidProcessor());
|
||||||
|
$logger->pushHandler(new RotatingFileHandler(__DIR__ . '/../var/log/app.log', 7, Logger::WARNING));
|
||||||
|
|
||||||
|
return $logger;
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
0
var/log/.gitkeep
Normal file
0
var/log/.gitkeep
Normal file
Loading…
Reference in New Issue
Block a user