Skip to content

Commit

Permalink
Erweiterung der Klassen (nicht fertig)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko Fenrich committed Jun 16, 2017
1 parent ef991fb commit b1f8e14
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/LoggerFactory.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php
namespace Depa\Logger;

use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\Log\Logger;
use Zend\Log\PsrLoggerAdapter;


class LoggerFactory implements FactoryInterface{
/**
* {@inheritDoc}
* @see \Zend\ServiceManager\Factory\FactoryInterface::__invoke()
*/
public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = null)
public function __invoke(ContainerInterface $container)
{
$config = $container->get('config');

Expand All @@ -22,7 +25,14 @@ public function __invoke(\Interop\Container\ContainerInterface $container, $requ
$loggerConfigArray = $config['logger'];

$zendLogLogger = new Logger();
$zendLogLogger->addWriter(new Stream($fileName));
$wr = new \Zend\Log\Writer\FirePHP();

new \Zend\Log\Writer\Noop();
$zendLogLogger->addWriter($wr);

$PsrLogger = new PsrLoggerAdapter($logger);

return ($PsrLogger);

}

Expand Down
36 changes: 36 additions & 0 deletions src/LoggerMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace Depa\Logger;

use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;





class LoggerMiddleware implements MiddlewareInterface
{
private $zendLogger;

public function __construct(LoggerInterface $logger)
{
$this->zendLogger = $logger;
}

/**
* {@inheritDoc}
*/
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
//was loggen???
$response = $delegate->process($request);


//was loggen?
return $response;


}
}
15 changes: 15 additions & 0 deletions src/LoggerMiddlewareFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Depa\Logger;

use Interop\Container\ContainerInterface;


class LoggerMiddlewareFactory
{
public function __invoke(ContainerInterface $container)
{


return new LoggerMiddleware();
}
}

0 comments on commit b1f8e14

Please sign in to comment.