SQL logger record complete statement #494
-
class SQLogger implements LoggerInterface
{
use LoggerTrait;
public function __construct(private readonly Aliases $aliases)
{
}
public function getLogger(DriverInterface $driver = null): LoggerInterface
{
return new Logger([new FileTarget($this->aliases->get('@runtime') . '/logs/sql.log')]);
}
/**
* @inheritDoc
*/
public function log(mixed $level, string|\Stringable $message, array $context = []): void
{
$this->getLogger()->log($level, $message, $context);
}
} Now sql is SELECT `woo_commerce_store`.`id` AS `c0`, `woo_commerce_store`.`name` AS `c1`, `woo_commerce_store`.`order_number_prefix` AS `c2`, `woo_commerce_store`.`third_party_account_id` AS `c3`,
`woo_commerce_store`.`website_url` AS `c4`, `woo_commerce_store`.`country_code` AS `c5`, `woo_commerce_store`.`currency_code` AS `c6`, `woo_commerce_store`.`timezone` AS `c7`,
`woo_commerce_store`.`api_key` AS `c8`, `woo_commerce_store`.`api_secret` AS `c9`, `woo_commerce_store`.`order_push_setting` AS `c10`, `woo_commerce_store`.`remark` AS `c11`,
`woo_commerce_store`.`status` AS `c12`, `woo_commerce_store`.`created_at` AS `c13`, `woo_commerce_store`.`created_by` AS `c14`, `woo_commerce_store`.`updated_at` AS `c15`,
`woo_commerce_store`.`updated_by` AS `c16`, `woo_commerce_store`.`is_deleted` AS `c17`, `woo_commerce_store`.`deleted_at` AS `c18`, `woo_commerce_store`.`deleted_by` AS `c19`,
`woo_commerce_store`.`created_at` AS `c20`, `woo_commerce_store`.`updated_at` AS `c21`
FROM `woo_commerce_store` AS `woo_commerce_store`
WHERE `woo_commerce_store`.`name` LIKE ?
ORDER BY `woo_commerce_store`.`created_at` DESC, `woo_commerce_store`.`updated_at` ASC
LIMIT ? OFFSET ? Can use final value replace '?' |
Beta Was this translation helpful? Give feedback.
Answered by
butschster
Aug 6, 2024
Replies: 1 comment 1 reply
-
hey. It can be done using your driver config new Config\PostgresDriverConfig(
connection: new Config\Postgres\TcpConnectionConfig(
...
),
options: [
'logQueryParameters' => true, // <====
'logInterpolatedQueries' => true,// <====
],
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
butschster
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey. It can be done using your driver config