aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2022-03-29 09:39:38 +0200
committerGitHub <noreply@github.com>2022-03-29 09:39:38 +0200
commit765999f454c0c5ebd8f2aa693d123f62d104d37a (patch)
treeee986c4dcb0edac3babb7ee87e5afc159087e2e0 /lib/private/DB/QueryBuilder
parent4a4f250a2b733f915e8b465bc995ea8ac18a8fbc (diff)
parent6d354595f71f15f3d15bce70683b4bc013a6bfaf (diff)
downloadnextcloud-server-765999f454c0c5ebd8f2aa693d123f62d104d37a.tar.gz
nextcloud-server-765999f454c0c5ebd8f2aa693d123f62d104d37a.zip
Merge pull request #31609 from nextcloud/fix/migrate-away-from-ilogger
Migrate from ILogger to LoggerInterface in lib/private
Diffstat (limited to 'lib/private/DB/QueryBuilder')
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index de326a2a317..4ecfd773492 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -53,7 +53,7 @@ use OCP\DB\QueryBuilder\ILiteral;
use OCP\DB\QueryBuilder\IParameter;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
-use OCP\ILogger;
+use Psr\Log\LoggerInterface;
class QueryBuilder implements IQueryBuilder {
@@ -63,8 +63,7 @@ class QueryBuilder implements IQueryBuilder {
/** @var SystemConfig */
private $systemConfig;
- /** @var ILogger */
- private $logger;
+ private LoggerInterface $logger;
/** @var \Doctrine\DBAL\Query\QueryBuilder */
private $queryBuilder;
@@ -83,9 +82,8 @@ class QueryBuilder implements IQueryBuilder {
*
* @param ConnectionAdapter $connection
* @param SystemConfig $systemConfig
- * @param ILogger $logger
*/
- public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, ILogger $logger) {
+ public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, LoggerInterface $logger) {
$this->connection = $connection;
$this->systemConfig = $systemConfig;
$this->logger = $logger;
@@ -229,8 +227,7 @@ class QueryBuilder implements IQueryBuilder {
}
} catch (\Error $e) {
// likely an error during conversion of $value to string
- $this->logger->debug('DB QueryBuilder: error trying to log SQL query');
- $this->logger->logException($e);
+ $this->logger->error('DB QueryBuilder: error trying to log SQL query', ['exception' => $e]);
}
}
@@ -245,11 +242,10 @@ class QueryBuilder implements IQueryBuilder {
if (empty($hasSelectAll) === empty($hasSelectSpecific)) {
$exception = new QueryException('Query is selecting * and specific values in the same query. This is not supported in Oracle.');
- $this->logger->logException($exception, [
- 'message' => 'Query is selecting * and specific values in the same query. This is not supported in Oracle.',
+ $this->logger->error($exception->getMessage(), [
'query' => $this->getSQL(),
- 'level' => ILogger::ERROR,
'app' => 'core',
+ 'exception' => $exception,
]);
}
}
@@ -266,21 +262,19 @@ class QueryBuilder implements IQueryBuilder {
if ($hasTooLargeArrayParameter) {
$exception = new QueryException('More than 1000 expressions in a list are not allowed on Oracle.');
- $this->logger->logException($exception, [
- 'message' => 'More than 1000 expressions in a list are not allowed on Oracle.',
+ $this->logger->error($exception->getMessage(), [
'query' => $this->getSQL(),
- 'level' => ILogger::ERROR,
'app' => 'core',
+ 'exception' => $exception,
]);
}
if ($numberOfParameters > 65535) {
$exception = new QueryException('The number of parameters must not exceed 65535. Restriction by PostgreSQL.');
- $this->logger->logException($exception, [
- 'message' => 'The number of parameters must not exceed 65535. Restriction by PostgreSQL.',
+ $this->logger->error($exception->getMessage(), [
'query' => $this->getSQL(),
- 'level' => ILogger::ERROR,
'app' => 'core',
+ 'exception' => $exception,
]);
}