My problem:
I want to save request and response for each call in a db table
I created a monolog handler in a symfony project.
I'm able to catch the log sent by the library listening the channell eight_points_guzzle, but the LogRecord has an empty context.
I'm a bit confused because the LogMiddleware populate the context (https://github.com/8p/EightPointsGuzzleBundle/blob/master/src/Middleware/LogMiddleware.php)
Am I missing something?
eight_points_guzzle.yaml
eight_points_guzzle:
logging: true
profiling: true
slow_response_time: 1000
clients:
MyClient:
logging: true
monolog.yaml
monolog:
handlers:
db:
type: service
channels: ['eight_points_guzzle']
id: monolog.eight_points_guzzle_db_handler
services.yaml
services:
# Monolog + Eight Points
monolog.eight_points_guzzle_db_handler:
class: App\Logger\ReqeuestLogger
arguments: ['@doctrine.orm.entity_manager']
RequestLogger.php
class RequestLogger extends AbstractProcessingHandler
{
private EntityManagerInterface $entityManager;
public function __construct(EntityManagerInterface $entityManager, $level = Level::Debug, bool $bubble = true)
{
$this->entityManager = $entityManager;
parent::__construct($level, $bubble);
}
protected function write(LogRecord $record): void
{
//$record['context'] should contain request and response but is empty
}
}
My problem:
I want to save request and response for each call in a db table
I created a monolog handler in a symfony project.
I'm able to catch the log sent by the library listening the channell
eight_points_guzzle, but the LogRecord has an empty context.I'm a bit confused because the LogMiddleware populate the context (https://github.com/8p/EightPointsGuzzleBundle/blob/master/src/Middleware/LogMiddleware.php)
Am I missing something?
eight_points_guzzle.yaml
monolog.yaml
services.yaml
RequestLogger.php