Compare commits
4 Commits
1.1.1
...
1f8d4f0bce
Author | SHA1 | Date | |
---|---|---|---|
1f8d4f0bce | |||
025697d37c | |||
de81f16557 | |||
c0ddd00cc6 |
@ -12,7 +12,7 @@ class Jobs
|
|||||||
{
|
{
|
||||||
use Json;
|
use Json;
|
||||||
|
|
||||||
public function schedule(ServerRequestInterface $request, ResponseInterface $response, Service $jobsService): ResponseInterface
|
public function schedule(ServerRequestInterface $request, ResponseInterface $response, Service $service, \ProVM\Common\Service\Messages $messagesService): ResponseInterface
|
||||||
{
|
{
|
||||||
$body = $request->getBody();
|
$body = $request->getBody();
|
||||||
$json = \Safe\json_decode($body->getContents());
|
$json = \Safe\json_decode($body->getContents());
|
||||||
@ -25,21 +25,24 @@ class Jobs
|
|||||||
'scheduled' => 0
|
'scheduled' => 0
|
||||||
];
|
];
|
||||||
foreach ($json->messages as $message_id) {
|
foreach ($json->messages as $message_id) {
|
||||||
if ($jobsService->schedule($message_id)) {
|
if ($service->schedule($message_id)) {
|
||||||
|
$message = $messagesService->getRepository()->fetchById($message_id);
|
||||||
|
$message->doesHaveScheduledDownloads();
|
||||||
|
$messagesService->getRepository()->save($message);
|
||||||
$output['scheduled'] ++;
|
$output['scheduled'] ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
public function pending(ServerRequestInterface $request, ResponseInterface $response, Service $jobsService): ResponseInterface
|
public function pending(ServerRequestInterface $request, ResponseInterface $response, Service $service): ResponseInterface
|
||||||
{
|
{
|
||||||
$pending = array_map(function(Job $job) {
|
$pending = array_map(function(Job $job) {
|
||||||
return $job->toArray();
|
return $job->toArray();
|
||||||
}, $jobsService->getPending());
|
}, $service->getPending());
|
||||||
$output = [
|
$output = [
|
||||||
'total' => count($pending),
|
'total' => count($pending),
|
||||||
'pending' => $pending
|
'pending' => $pending
|
||||||
];
|
];
|
||||||
return $this->withJson($response, $output);
|
return $this->withJson($response, $output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
api/common/Middleware/Logging.php
Normal file
38
api/common/Middleware/Logging.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProVM\Common\Middleware;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Logging
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger) {
|
||||||
|
$this->setLogger($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LoggerInterface $logger;
|
||||||
|
|
||||||
|
public function getLogger(): LoggerInterface
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLogger(LoggerInterface $logger): Logging
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
|
{
|
||||||
|
$response = $handler->handle($request);
|
||||||
|
$output = [
|
||||||
|
'uri' => var_export($request->getUri(), true),
|
||||||
|
'body' => $request->getBody()->getContents()
|
||||||
|
];
|
||||||
|
$this->getLogger()->info(\Safe\json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,11 @@ Monolog\ErrorHandler::register($app->getContainer()->get(Psr\Log\LoggerInterface
|
|||||||
try {
|
try {
|
||||||
$app->run();
|
$app->run();
|
||||||
} catch (Error | Exception $e) {
|
} catch (Error | Exception $e) {
|
||||||
$app->getContainer()->get(Psr\Log\LoggerInterface::class)->error($e);
|
$logger = $app->getContainer()->get(Psr\Log\LoggerInterface::class);
|
||||||
|
if (isset($_REQUEST)) {
|
||||||
|
$logger->debug(Safe\json_encode(compact('_REQUEST')));
|
||||||
|
}
|
||||||
|
$logger->debug(Safe\json_encode(compact('_SERVER')));
|
||||||
|
$logger->error($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
2
api/setup/middleware/98_log.php
Normal file
2
api/setup/middleware/98_log.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
$app->add($app->getContainer()->get(ProVM\Common\Middleware\Logging::class));
|
@ -18,4 +18,5 @@ return [
|
|||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
'attachments_folder' => $_ENV['ATTACHMENTS_FOLDER'],
|
'attachments_folder' => $_ENV['ATTACHMENTS_FOLDER'],
|
||||||
];
|
'logs_folder' => '/logs',
|
||||||
|
];
|
||||||
|
@ -7,5 +7,8 @@ return [
|
|||||||
$container->get(Nyholm\Psr7\Factory\Psr17Factory::class),
|
$container->get(Nyholm\Psr7\Factory\Psr17Factory::class),
|
||||||
$container->get(Psr\Log\LoggerInterface::class)
|
$container->get(Psr\Log\LoggerInterface::class)
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
ProVM\Common\Middleware\Logging::class => function(ContainerInterface $container) {
|
||||||
|
return new ProVM\Common\Middleware\Logging($container->get('request_logger'));
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -10,13 +10,23 @@ return [
|
|||||||
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
||||||
return $handler;
|
return $handler;
|
||||||
},
|
},
|
||||||
|
'request_logger' => function(ContainerInterface $container) {
|
||||||
|
$logger = new Monolog\Logger('request_logger');
|
||||||
|
$handler = new Monolog\Handler\RotatingFileHandler(implode(DIRECTORY_SEPARATOR, [$container->get('logs_folder'), 'requests.log']));
|
||||||
|
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
||||||
|
$dedupHandler = new Monolog\Handler\DeduplicationHandler($handler, null, Monolog\Level::Info);
|
||||||
|
$logger->pushHandler($dedupHandler);
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
|
return $logger;
|
||||||
|
},
|
||||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||||
$logger = new Monolog\Logger('file_logger');
|
$logger = new Monolog\Logger('file_logger');
|
||||||
$logger->pushHandler($container->get(Monolog\Handler\DeduplicationHandler::class));
|
$logger->pushHandler($container->get(Monolog\Handler\DeduplicationHandler::class));
|
||||||
//$logger->pushHandler($container->get(Monolog\Handler\RotatingFileHandler::class));
|
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
return $logger;
|
return $logger;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -108,7 +108,12 @@ class Message implements Model
|
|||||||
}
|
}
|
||||||
public function getState(string $name): \ProVM\Emails\Model\State\Message
|
public function getState(string $name): \ProVM\Emails\Model\State\Message
|
||||||
{
|
{
|
||||||
return $this->getStates()[$name];
|
try {
|
||||||
|
return $this->getStates()[$name];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->newState($name);
|
||||||
|
return $this->getStates()[$name];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function addState(\ProVM\Emails\Model\State\Message $state): Message
|
public function addState(\ProVM\Emails\Model\State\Message $state): Message
|
||||||
{
|
{
|
||||||
@ -127,6 +132,7 @@ class Message implements Model
|
|||||||
$this->addState((new \ProVM\Emails\Model\State\Message())
|
$this->addState((new \ProVM\Emails\Model\State\Message())
|
||||||
->setName($name)
|
->setName($name)
|
||||||
->setMessage($this)
|
->setMessage($this)
|
||||||
|
->setValue(false)
|
||||||
);
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -143,31 +149,31 @@ class Message implements Model
|
|||||||
{
|
{
|
||||||
return $this->getState('downloaded_attachments')->getValue() ?? false;
|
return $this->getState('downloaded_attachments')->getValue() ?? false;
|
||||||
}
|
}
|
||||||
|
public function hasScheduledDownloads(): bool
|
||||||
|
{
|
||||||
|
return $this->getState('scheduled_downloads')->getValue() ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
public function doesHaveAttachments(): Message
|
public function doesHaveAttachments(): Message
|
||||||
{
|
{
|
||||||
if (!isset($this->getStates()['has_attachments'])) {
|
|
||||||
$this->newState('has_attachments');
|
|
||||||
}
|
|
||||||
$this->getState('has_attachments')->setValue(true);
|
$this->getState('has_attachments')->setValue(true);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function doesHaveValidAttachments(): Message
|
public function doesHaveValidAttachments(): Message
|
||||||
{
|
{
|
||||||
if (!isset($this->getStates()['valid_attachments'])) {
|
|
||||||
$this->newState('valid_attachments');
|
|
||||||
}
|
|
||||||
$this->getState('valid_attachments')->setValue(true);
|
$this->getState('valid_attachments')->setValue(true);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
public function doesHaveDownloadedAttachments(): Message
|
public function doesHaveDownloadedAttachments(): Message
|
||||||
{
|
{
|
||||||
if (!isset($this->getStates()['downloaded_attachments'])) {
|
|
||||||
$this->newState('downloaded_attachments');
|
|
||||||
}
|
|
||||||
$this->getState('downloaded_attachments')->setValue(true);
|
$this->getState('downloaded_attachments')->setValue(true);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function doesHaveScheduledDownloads(): Message
|
||||||
|
{
|
||||||
|
$this->getState('scheduled_downloads')->setValue(true);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected array $attachments;
|
protected array $attachments;
|
||||||
public function getAttachments(): array
|
public function getAttachments(): array
|
||||||
@ -205,11 +211,12 @@ class Message implements Model
|
|||||||
'states' => [
|
'states' => [
|
||||||
'has_attachments' => $this->hasAttachments(),
|
'has_attachments' => $this->hasAttachments(),
|
||||||
'valid_attachments' => $this->hasValidAttachments(),
|
'valid_attachments' => $this->hasValidAttachments(),
|
||||||
'downloaded_attachments' => $this->hasDownloadedAttachments()
|
'downloaded_attachments' => $this->hasDownloadedAttachments(),
|
||||||
|
'scheduled_downloads' => $this->hasScheduledDownloads()
|
||||||
],
|
],
|
||||||
'attachments' => $this->hasValidAttachments() ? array_map(function(Attachment $attachment) {
|
'attachments' => $this->hasValidAttachments() ? array_map(function(Attachment $attachment) {
|
||||||
return $attachment->toArray();
|
return $attachment->toArray();
|
||||||
}, $this->getAttachments()) : []
|
}, $this->getAttachments()) : []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,8 @@ class Message extends Repository
|
|||||||
$valid_states = [
|
$valid_states = [
|
||||||
'has_attachments',
|
'has_attachments',
|
||||||
'valid_attachments',
|
'valid_attachments',
|
||||||
'downloaded_attachments'
|
'downloaded_attachments',
|
||||||
|
'scheduled_downloads'
|
||||||
];
|
];
|
||||||
foreach ($valid_states as $state_name) {
|
foreach ($valid_states as $state_name) {
|
||||||
try {
|
try {
|
||||||
@ -160,4 +161,4 @@ class Message extends Repository
|
|||||||
WHERE `mailbox_id` = ? `subject` = ? AND `from` = ? AND `date_time` = ?";
|
WHERE `mailbox_id` = ? `subject` = ? AND `from` = ? AND `date_time` = ?";
|
||||||
return $this->fetchOne($query, [$mailbox_id, $subject, $from, $dateTime->format('Y-m-d H:i:s')]);
|
return $this->fetchOne($query, [$mailbox_id, $subject, $from, $dateTime->format('Y-m-d H:i:s')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
cli/common/Middleware/Logging.php
Normal file
38
cli/common/Middleware/Logging.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProVM\Common\Middleware;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Logging
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger) {
|
||||||
|
$this->setLogger($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LoggerInterface $logger;
|
||||||
|
|
||||||
|
public function getLogger(): LoggerInterface
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLogger(LoggerInterface $logger): Logging
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
|
{
|
||||||
|
$response = $handler->handle($request);
|
||||||
|
$output = [
|
||||||
|
'uri' => var_export($request->getUri(), true),
|
||||||
|
'body' => $request->getBody()->getContents()
|
||||||
|
];
|
||||||
|
$this->getLogger()->info(\Safe\json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,12 @@ $app = require_once implode(DIRECTORY_SEPARATOR, [
|
|||||||
'setup',
|
'setup',
|
||||||
'app.php'
|
'app.php'
|
||||||
]);
|
]);
|
||||||
|
Monolog\ErrorHandler::register($app->getContainer()->get(Psr\Log\LoggerInterface::class));
|
||||||
try {
|
try {
|
||||||
$app->run();
|
$app->run();
|
||||||
} catch (Error | Exception $e) {
|
} catch (Error | Exception $e) {
|
||||||
$app->getContainer()->get(\Psr\Log\LoggerInterface::class)->error($e);
|
$logger = $app->getContainer()->get(Psr\Log\LoggerInterface::class);
|
||||||
|
$logger->debug(Safe\json_encode(compact('_SERVER')));
|
||||||
|
$logger->error($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
2
cli/setup/middleware/98_log.php
Normal file
2
cli/setup/middleware/98_log.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
$app->add($app->getContainer()->get(ProVM\Common\Middleware\Logging::class));
|
@ -14,5 +14,6 @@ return [
|
|||||||
$container->get('resources_folder'),
|
$container->get('resources_folder'),
|
||||||
'commands'
|
'commands'
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
'logs_folder' => '/logs',
|
||||||
];
|
];
|
||||||
|
8
cli/setup/setups/03_middleware.php
Normal file
8
cli/setup/setups/03_middleware.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
return [
|
||||||
|
ProVM\Common\Middleware\Logging::class => function(ContainerInterface $container) {
|
||||||
|
return new ProVM\Common\Middleware\Logging($container->get('request_logger'));
|
||||||
|
}
|
||||||
|
];
|
@ -2,14 +2,28 @@
|
|||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
\Monolog\Handler\RotatingFileHandler::class => function(ContainerInterface $container) {
|
Monolog\Handler\RotatingFileHandler::class => function(ContainerInterface $container) {
|
||||||
$handler = new \Monolog\Handler\RotatingFileHandler($container->get('log_file'));
|
$handler = new Monolog\Handler\RotatingFileHandler($container->get('log_file'));
|
||||||
$handler->setFormatter($container->get(\Monolog\Formatter\LineFormatter::class));
|
$handler->setFormatter($container->get(Monolog\Formatter\LineFormatter::class));
|
||||||
return $handler;
|
return $handler;
|
||||||
},
|
},
|
||||||
\Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
'request_logger' => function(ContainerInterface $container) {
|
||||||
$logger = new \Monolog\Logger('file_logger');
|
$logger = new Monolog\Logger('request_logger');
|
||||||
$logger->pushHandler($container->get(\Monolog\Handler\RotatingFileHandler::class));
|
$handler = new Monolog\Handler\RotatingFileHandler(implode(DIRECTORY_SEPARATOR, [$container->get('logs_folder'), 'requests.log']));
|
||||||
|
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
||||||
|
$dedupHandler = new Monolog\Handler\DeduplicationHandler($handler, null, Monolog\Level::Info);
|
||||||
|
$logger->pushHandler($dedupHandler);
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
return $logger;
|
return $logger;
|
||||||
}
|
},
|
||||||
];
|
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||||
|
$logger = new Monolog\Logger('file_logger');
|
||||||
|
$logger->pushHandler($container->get(Monolog\Handler\RotatingFileHandler::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
|
return $logger;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
@ -4,14 +4,13 @@ namespace ProVM\Common\Controller;
|
|||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use ProVM\Common\Service\Api as Service;
|
use ProVM\Common\Service\Api as Service;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Api
|
class Api
|
||||||
{
|
{
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service $service): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Service $service, LoggerInterface $logger): ResponseInterface
|
||||||
{
|
{
|
||||||
$body = $request->getBody();
|
$json = $request->getParsedBody();
|
||||||
$json = \Safe\json_decode($body->getContents(), JSON_OBJECT_AS_ARRAY);
|
|
||||||
|
|
||||||
return $service->sendRequest($json);
|
return $service->sendRequest($json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
38
ui/common/Middleware/Logging.php
Normal file
38
ui/common/Middleware/Logging.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProVM\Common\Middleware;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
class Logging
|
||||||
|
{
|
||||||
|
public function __construct(LoggerInterface $logger) {
|
||||||
|
$this->setLogger($logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LoggerInterface $logger;
|
||||||
|
|
||||||
|
public function getLogger(): LoggerInterface
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLogger(LoggerInterface $logger): Logging
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
|
{
|
||||||
|
$response = $handler->handle($request);
|
||||||
|
$output = [
|
||||||
|
'uri' => var_export($request->getUri(), true),
|
||||||
|
'body' => $request->getParsedBody()
|
||||||
|
];
|
||||||
|
$this->getLogger()->info(\Safe\json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,11 @@ Monolog\ErrorHandler::register($app->getContainer()->get(Psr\Log\LoggerInterface
|
|||||||
try {
|
try {
|
||||||
$app->run();
|
$app->run();
|
||||||
} catch (Error | Exception $e) {
|
} catch (Error | Exception $e) {
|
||||||
$app->getContainer()->get(Psr\Log\LoggerInterface::class)->error($e);
|
$logger = $app->getContainer()->get(Psr\Log\LoggerInterface::class);
|
||||||
|
if (isset($_REQUEST)) {
|
||||||
|
$logger->debug(Safe\json_encode(compact('_REQUEST')));
|
||||||
|
}
|
||||||
|
$logger->debug(Safe\json_encode(compact('_SERVER')));
|
||||||
|
$logger->error($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use ProVM\Common\Controller\Api;
|
use ProVM\Common\Controller\Api;
|
||||||
|
|
||||||
$app->post('/api', Api::class);
|
$app->post('/api[/]', Api::class);
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
states = {
|
states = {
|
||||||
attachments: false,
|
attachments: false,
|
||||||
valid: false,
|
valid: false,
|
||||||
downloaded: false
|
downloaded: false,
|
||||||
|
scheduled: false
|
||||||
}
|
}
|
||||||
attachments
|
attachments
|
||||||
|
|
||||||
@ -81,10 +82,15 @@
|
|||||||
const map_keys = {
|
const map_keys = {
|
||||||
has_attachments: 'attachments',
|
has_attachments: 'attachments',
|
||||||
valid_attachments: 'valid',
|
valid_attachments: 'valid',
|
||||||
downloaded_attachments: 'downloaded'
|
downloaded_attachments: 'downloaded',
|
||||||
|
scheduled_downloads: 'scheduled'
|
||||||
}
|
}
|
||||||
Object.keys(states).forEach(k => {
|
Object.keys(states).forEach(k => {
|
||||||
this.states[map_keys[k]] = states[k]
|
if (k in map_keys) {
|
||||||
|
this.states[map_keys[k]] = states[k]
|
||||||
|
} else {
|
||||||
|
this.states[map_keys[k]] = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
@ -103,6 +109,9 @@
|
|||||||
},
|
},
|
||||||
downloaded: () => {
|
downloaded: () => {
|
||||||
return this.states.downloaded
|
return this.states.downloaded
|
||||||
|
},
|
||||||
|
scheduled: () => {
|
||||||
|
return this.states.scheduled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,80 +128,99 @@
|
|||||||
downloaded: () => {
|
downloaded: () => {
|
||||||
this.states.downloaded = true
|
this.states.downloaded = true
|
||||||
return this
|
return this
|
||||||
|
},
|
||||||
|
scheduled: () => {
|
||||||
|
this.states.scheduled = true
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
const format = Intl.DateTimeFormat('es-CL', {dateStyle: 'full', timeStyle: 'short'})
|
return {
|
||||||
let date = new Date()
|
row: () => {
|
||||||
try {
|
const format = Intl.DateTimeFormat('es-CL', {dateStyle: 'full', timeStyle: 'short'})
|
||||||
date = new Date(this.get().date())
|
let date = new Date()
|
||||||
} catch (e) {
|
try {
|
||||||
console.debug(e)
|
date = new Date(this.get().date())
|
||||||
}
|
} catch (e) {
|
||||||
const valid = $('<td></td>').html($('<i></i>').addClass(this.has().valid() ? 'green check circle icon' : 'red times circle icon'))
|
console.debug(e)
|
||||||
if (this.has().valid() && this.get().attachments().length > 0) {
|
|
||||||
const list = $('<div></div>').addClass('ui list')
|
|
||||||
this.get().attachments().forEach(attachment => {
|
|
||||||
list.append($('<div></div>').addClass('item').html(attachment.filename))
|
|
||||||
})
|
|
||||||
valid.append(
|
|
||||||
$('<div></div>').addClass('ui popup').append(list)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
const tr = $('<tr></tr>').append(
|
|
||||||
$('<td></td>').html(this.get().subject())
|
|
||||||
).append(
|
|
||||||
$('<td></td>').html(format.format(date))
|
|
||||||
).append(
|
|
||||||
$('<td></td>').html(this.get().from().full)
|
|
||||||
).append(
|
|
||||||
$('<td></td>').html($('<i></i>').addClass(this.has().attachments() ? 'green check circle icon' : 'red times circle icon'))
|
|
||||||
).append(
|
|
||||||
valid
|
|
||||||
).append(
|
|
||||||
$('<td></td>').html($('<i></i>').addClass(this.has().downloaded() ? 'green check circle icon' : 'red times circle icon'))
|
|
||||||
).append(
|
|
||||||
$('<td></td>').append(
|
|
||||||
(this.has().attachments() && this.has().valid() && !this.has().downloaded()) ?
|
|
||||||
$('<button></button>').addClass('ui mini green circular icon button').append(
|
|
||||||
$('<i></i>').addClass('clock icon')
|
|
||||||
).click(() => {
|
|
||||||
this.download().attachments(this.get().id())
|
|
||||||
}) : ''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if (this.has().downloaded()) {
|
|
||||||
tr.find('td').each((i, td) => {
|
|
||||||
const content = $(td).html()
|
|
||||||
if (content.indexOf('icon') > -1) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
$(td).html('')
|
const valid = $('<td></td>').html($('<i></i>').addClass(this.has().valid() ? 'green check circle icon' : 'red times circle icon'))
|
||||||
$(td).append(
|
if (this.has().valid() && this.get().attachments().length > 0) {
|
||||||
$('<a></a>').attr('href', '{{$urls->base}}/emails/message/' + this.id).html(content)
|
const list = $('<div></div>').addClass('ui list')
|
||||||
|
this.get().attachments().forEach(attachment => {
|
||||||
|
list.append($('<div></div>').addClass('item').html(attachment.filename))
|
||||||
|
})
|
||||||
|
valid.append(
|
||||||
|
$('<div></div>').addClass('ui popup').append(list)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const tr = $('<tr></tr>').attr('data-id', this.get().id()).append(
|
||||||
|
$('<td></td>').html(this.get().subject())
|
||||||
|
).append(
|
||||||
|
$('<td></td>').html(format.format(date))
|
||||||
|
).append(
|
||||||
|
$('<td></td>').html(this.get().from().full)
|
||||||
|
).append(
|
||||||
|
$('<td></td>').html($('<i></i>').addClass(this.has().attachments() ? 'green check circle icon' : 'red times circle icon'))
|
||||||
|
).append(
|
||||||
|
valid
|
||||||
|
).append(
|
||||||
|
$('<td></td>').html($('<i></i>').addClass(this.has().downloaded() ? 'green check circle icon' : 'red times circle icon'))
|
||||||
|
).append(
|
||||||
|
$('<td></td>').append(
|
||||||
|
(this.has().attachments() && this.has().valid() && !this.has().downloaded()) ?
|
||||||
|
((this.has().scheduled()) ? this.draw().scheduledButton() : this.draw().scheduleButton()) : ''
|
||||||
|
)
|
||||||
)
|
)
|
||||||
})
|
if (this.has().downloaded()) {
|
||||||
|
tr.find('td').each((i, td) => {
|
||||||
|
const content = $(td).html()
|
||||||
|
if (content.indexOf('icon') > -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$(td).html('')
|
||||||
|
$(td).append(
|
||||||
|
$('<a></a>').attr('href', '{{$urls->base}}/emails/message/' + this.id).html(content)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return tr
|
||||||
|
},
|
||||||
|
scheduleButton: () => {
|
||||||
|
return $('<button></button>').addClass('ui mini circular icon button').append(
|
||||||
|
$('<i></i>').addClass('clock icon')
|
||||||
|
).click(e => {
|
||||||
|
this.download().attachments(e)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
scheduledButton: () => {
|
||||||
|
return $('<i></i>').addClass('ui green circular inverted check icon')
|
||||||
|
},
|
||||||
|
schedulingButton: () => {
|
||||||
|
return $('<i></i>').addClass('ui circular inverted redo loading icon')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
return {
|
return {
|
||||||
attachments: id => {
|
attachments: event => {
|
||||||
|
const td = $(event.currentTarget).parent()
|
||||||
|
const id = this.get().id()
|
||||||
const uri = '/messages/schedule'
|
const uri = '/messages/schedule'
|
||||||
const data = {
|
const data = {
|
||||||
messages: [
|
messages: [
|
||||||
id
|
id
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
td.html('').append(this.draw().schedulingButton())
|
||||||
return Send.put({
|
return Send.put({
|
||||||
uri,
|
uri,
|
||||||
data
|
data
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.scheduled > 0) {
|
if (response.scheduled > 0) {
|
||||||
alert('Scheduled Attachments Job')
|
td.html('').append(this.draw().scheduledButton())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -205,9 +233,6 @@
|
|||||||
name: '',
|
name: '',
|
||||||
count: ''
|
count: ''
|
||||||
},
|
},
|
||||||
page: 1,
|
|
||||||
current: 0,
|
|
||||||
shown: 10,
|
|
||||||
total: null,
|
total: null,
|
||||||
visible: [],
|
visible: [],
|
||||||
get: function() {
|
get: function() {
|
||||||
@ -250,7 +275,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
draw: function() {
|
draw: function() {
|
||||||
const columns = 8
|
|
||||||
return {
|
return {
|
||||||
loader: () => {
|
loader: () => {
|
||||||
$(this.id.results).html('').append(
|
$(this.id.results).html('').append(
|
||||||
@ -270,8 +294,6 @@
|
|||||||
this.draw().head()
|
this.draw().head()
|
||||||
).append(
|
).append(
|
||||||
this.draw().body()
|
this.draw().body()
|
||||||
).append(
|
|
||||||
this.draw().footer()
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
head: () => {
|
head: () => {
|
||||||
@ -286,43 +308,8 @@
|
|||||||
}
|
}
|
||||||
values.push(v)
|
values.push(v)
|
||||||
}
|
}
|
||||||
const dropdown = $('<div></div>').addClass('ui scrolling dropdown').append(
|
|
||||||
$('<i></i>').addClass('dropdown icon')
|
|
||||||
).append(
|
|
||||||
$('<div></div>').addClass('text').html(this.shown)
|
|
||||||
).dropdown({
|
|
||||||
values,
|
|
||||||
onChange: (value, text, $choice) => {
|
|
||||||
if (value === this.shown) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.shown = parseInt(value)
|
|
||||||
// Trigger pending transition
|
|
||||||
$choice.parent().parent().dropdown('hide')
|
|
||||||
this.get()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return $('<thead></thead>').append(
|
return $('<thead></thead>').append(
|
||||||
$('<tr></tr>').append(
|
|
||||||
$('<th></th>').addClass('right aligned').attr('colspan', columns).append(
|
|
||||||
dropdown
|
|
||||||
).append(
|
|
||||||
$('<span></span>').addClass('ui basic label').html((this.current + 1) + ' - ' + Math.min(this.shown + this.current, this.total ?? 99999999))
|
|
||||||
).append(
|
|
||||||
$('<button></button>').addClass('ui mini circular icon button').append(
|
|
||||||
$('<i></i>').addClass('left chevron icon')
|
|
||||||
).click(() => {
|
|
||||||
this.prev()
|
|
||||||
})
|
|
||||||
).append(
|
|
||||||
$('<button></button>').addClass('ui mini circular icon button').append(
|
|
||||||
$('<i></i>').addClass('right chevron icon')
|
|
||||||
).click(() => {
|
|
||||||
this.next()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).append(
|
|
||||||
$('<tr></tr>').append(
|
$('<tr></tr>').append(
|
||||||
$('<th></th>').html('#')
|
$('<th></th>').html('#')
|
||||||
).append(
|
).append(
|
||||||
@ -345,7 +332,7 @@
|
|||||||
body: () => {
|
body: () => {
|
||||||
const tbody = $('<tbody></tbody>')
|
const tbody = $('<tbody></tbody>')
|
||||||
this.visible.forEach((m, i) => {
|
this.visible.forEach((m, i) => {
|
||||||
const row = m.draw()
|
const row = m.draw().row()
|
||||||
row.prepend(
|
row.prepend(
|
||||||
$('<td></td>').html(i + this.current + 1)
|
$('<td></td>').html(i + this.current + 1)
|
||||||
)
|
)
|
||||||
@ -353,95 +340,12 @@
|
|||||||
})
|
})
|
||||||
return tbody
|
return tbody
|
||||||
},
|
},
|
||||||
footer: () => {
|
|
||||||
const pages = this.lastPage()
|
|
||||||
const paging = $('<div></div>').addClass('ui right floated pagination menu')
|
|
||||||
if (this.page !== 1) {
|
|
||||||
paging.append(
|
|
||||||
$('<a></a>').addClass('icon item').append(
|
|
||||||
$('<i></i>').addClass('step backward icon')
|
|
||||||
).click(() => {
|
|
||||||
this.first()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
for (let i = 0; i < pages; i ++) {
|
|
||||||
const page = $('<a></a>').addClass('item').html(i + 1).click(() => {
|
|
||||||
this.goto(i + 1)
|
|
||||||
})
|
|
||||||
if (i + 1 === this.page) {
|
|
||||||
page.addClass('active')
|
|
||||||
}
|
|
||||||
paging.append(page)
|
|
||||||
}
|
|
||||||
if (this.page !== this.lastPage()) {
|
|
||||||
paging.append(
|
|
||||||
$('<a></a>').addClass('icon item').append(
|
|
||||||
$('<i></i>').addClass('step forward icon')
|
|
||||||
).click(() => {
|
|
||||||
this.last()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return $('<tfoot></tfoot>').append(
|
|
||||||
$('<tr></tr>').append(
|
|
||||||
$('<th></th>').attr('colspan', columns).append(paging)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
empty: () => {
|
empty: () => {
|
||||||
$(this.id.count).html(' (0)')
|
$(this.id.count).html(' (0)')
|
||||||
return $('<div></div>').addClass('ui message').html('No messages found.')
|
return $('<div></div>').addClass('ui message').html('No messages found.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lastPage: function() {
|
|
||||||
let pages = Math.floor(this.total / this.shown)
|
|
||||||
if (this.total / this.shown > pages) {
|
|
||||||
pages ++
|
|
||||||
}
|
|
||||||
return pages
|
|
||||||
},
|
|
||||||
first: function() {
|
|
||||||
if (this.current === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.page = 1
|
|
||||||
this.current = 0
|
|
||||||
this.get()
|
|
||||||
},
|
|
||||||
next: function() {
|
|
||||||
if (this.current + this.shown >= this.total) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.page ++
|
|
||||||
this.current += this.shown
|
|
||||||
this.get()
|
|
||||||
},
|
|
||||||
goto: function(page) {
|
|
||||||
if (this.page === page) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.page = page
|
|
||||||
this.current = (this.page - 1) * this.shown
|
|
||||||
this.get()
|
|
||||||
},
|
|
||||||
prev: function() {
|
|
||||||
if (this.current < this.shown) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.page --
|
|
||||||
this.current -= this.shown
|
|
||||||
this.get()
|
|
||||||
},
|
|
||||||
last: function() {
|
|
||||||
if (this.page === this.lastPage()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.page = this.lastPage()
|
|
||||||
this.current = (this.page - 1) * this.shown
|
|
||||||
this.get()
|
|
||||||
},
|
|
||||||
setup: function() {
|
setup: function() {
|
||||||
this.get().mailbox().then(() => {
|
this.get().mailbox().then(() => {
|
||||||
this.get().messages()
|
this.get().messages()
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
@section('emails_content')
|
@section('emails_content')
|
||||||
<h3>Message - <span id="subject"></span> - <span id="from"></span></h3>
|
<h3>Message - <span id="subject"></span> - <span id="from"></span></h3>
|
||||||
<h4 id="date_time"></h4>
|
<h4 id="date_time"></h4>
|
||||||
<div class="ui list" id="attachments"></div>
|
<div class="ui bulleted link list" id="attachments"></div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
@ -82,7 +82,7 @@
|
|||||||
attachments: parent => {
|
attachments: parent => {
|
||||||
this.get().attachments().forEach(attachment => {
|
this.get().attachments().forEach(attachment => {
|
||||||
parent.append(
|
parent.append(
|
||||||
$('<a></a>').attr('href', _urls.base + '/attachment/' + attachment.id).attr('download', attachment.fullname).html(attachment.fullname)
|
$('<a></a>').attr('href', '{{$urls->base}}/attachment/' + attachment.id).attr('download', attachment.fullname).html(attachment.fullname)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -100,4 +100,4 @@
|
|||||||
message.setup('{{$message_id}}')
|
message.setup('{{$message_id}}')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -3,18 +3,17 @@
|
|||||||
base_url: '{{$urls->api}}',
|
base_url: '{{$urls->api}}',
|
||||||
base: function({method, uri, data = null}) {
|
base: function({method, uri, data = null}) {
|
||||||
const request = {
|
const request = {
|
||||||
uri: uri.replace(/^\//g, ''),
|
uri: uri,
|
||||||
method
|
method
|
||||||
}
|
}
|
||||||
const options = {
|
const options = {
|
||||||
url: this.base_url,
|
url: this.base_url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
contentType: 'application/json'
|
|
||||||
}
|
}
|
||||||
if (method.toLowerCase() !== 'get' && data !== null) {
|
if (method.toLowerCase() !== 'get' && data !== null) {
|
||||||
request['data'] = data
|
request['data'] = data
|
||||||
}
|
}
|
||||||
options['data'] = JSON.stringify(request)
|
options['data'] = request
|
||||||
return $.ajax(options)
|
return $.ajax(options)
|
||||||
},
|
},
|
||||||
get: function(uri) {
|
get: function(uri) {
|
||||||
@ -30,5 +29,5 @@
|
|||||||
return this.base({method: 'delete', uri, data})
|
return this.base({method: 'delete', uri, data})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const _urls = JSON.parse('{!! Safe\json_encode($urls) !!}')
|
//const _urls = JSON.parse('{!! Safe\json_encode($urls) !!}')
|
||||||
</script>
|
</script>
|
||||||
|
2
ui/setup/middleware/98_log.php
Normal file
2
ui/setup/middleware/98_log.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
$app->add($app->getContainer()->get(ProVM\Common\Middleware\Logging::class));
|
@ -20,6 +20,7 @@ return [
|
|||||||
$arr['base'],
|
$arr['base'],
|
||||||
'cache'
|
'cache'
|
||||||
]);
|
]);
|
||||||
|
$arr['logs'] = '/logs';
|
||||||
return (object) $arr;
|
return (object) $arr;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -4,7 +4,7 @@ use Psr\Container\ContainerInterface;
|
|||||||
return [
|
return [
|
||||||
Psr\Http\Client\ClientInterface::class => function(ContainerInterface $container) {
|
Psr\Http\Client\ClientInterface::class => function(ContainerInterface $container) {
|
||||||
return new GuzzleHttp\Client([
|
return new GuzzleHttp\Client([
|
||||||
'base_uri' => "http://proxy:8080",
|
'base_uri' => $container->get('urls')->api,
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => [
|
'Authorization' => [
|
||||||
"Bearer {$container->get('api_key')}"
|
"Bearer {$container->get('api_key')}"
|
||||||
@ -15,4 +15,4 @@ return [
|
|||||||
Psr\Http\Message\RequestFactoryInterface::class => function(ContainerInterface $container) {
|
Psr\Http\Message\RequestFactoryInterface::class => function(ContainerInterface $container) {
|
||||||
return $container->get(Nyholm\Psr7\Factory\Psr17Factory::class);
|
return $container->get(Nyholm\Psr7\Factory\Psr17Factory::class);
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
8
ui/setup/setups/04_middleware.php
Normal file
8
ui/setup/setups/04_middleware.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
return [
|
||||||
|
ProVM\Common\Middleware\Logging::class => function(ContainerInterface $container) {
|
||||||
|
return new ProVM\Common\Middleware\Logging($container->get('request_logger'));
|
||||||
|
}
|
||||||
|
];
|
@ -10,13 +10,23 @@ return [
|
|||||||
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
||||||
return $handler;
|
return $handler;
|
||||||
},
|
},
|
||||||
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
'request_logger' => function(ContainerInterface $container) {
|
||||||
$logger = new Monolog\Logger('file_logger');
|
$logger = new Monolog\Logger('request_logger');
|
||||||
$logger->pushHandler($container->get(Monolog\Handler\DeduplicationHandler::class));
|
$handler = new Monolog\Handler\RotatingFileHandler(implode(DIRECTORY_SEPARATOR, [$container->get('folders')->logs, 'requests.log']));
|
||||||
//$logger->pushHandler($container->get(Monolog\Handler\RotatingFileHandler::class));
|
$handler->setFormatter($container->get(Monolog\Formatter\SyslogFormatter::class));
|
||||||
|
$dedupHandler = new Monolog\Handler\DeduplicationHandler($handler, null, Monolog\Level::Info);
|
||||||
|
$logger->pushHandler($dedupHandler);
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
return $logger;
|
return $logger;
|
||||||
}
|
},
|
||||||
];
|
Psr\Log\LoggerInterface::class => function(ContainerInterface $container) {
|
||||||
|
$logger = new Monolog\Logger('file_logger');
|
||||||
|
$logger->pushHandler($container->get(Monolog\Handler\DeduplicationHandler::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\PsrLogMessageProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\IntrospectionProcessor::class));
|
||||||
|
$logger->pushProcessor($container->get(Monolog\Processor\MemoryUsageProcessor::class));
|
||||||
|
return $logger;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
Reference in New Issue
Block a user