-
-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the connection name to logs #1687
Labels
Comments
I think this would make sense 👍 But this would probably involve contributing to the DBAL Middleware code to make it possible to pass additional information (like the connection name) into the logging context? |
We could perhaps inject logger to Middleware with certain monolog processor attached |
Or maybe a psr logger decorator could also do the job? 🤔 use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface;
class ConnectionNameAwareLogger extends AbstractLogger
{
public function __construct(private LoggerInterface $decoratedLogger, private string $connectionName)
{
}
public function log($level, \Stringable|string $message, array $context = []): void
{
$this->decoratedLogger->log($level, $message, ['doctrine.dbal.connection_name' => $this->connectionName] + $context);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
First, thank you for this amazing package!
I'm using the bundle with several connections and here is a suggestion after playing with logs.
Logs with the dedicated
Doctrine\DBAL\Logging\Middleware
are lacking the connection name used by the bundle.Right now, it is impossible to know which connection is related to a given log.
Thanks!
The text was updated successfully, but these errors were encountered: