-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimPod\ClickHouseClient\Logger; | ||
|
||
final class LoggerChain implements SqlLogger | ||
{ | ||
/** @var SqlLogger[] */ | ||
private array $loggers; | ||
|
||
/** @param SqlLogger[] $loggers */ | ||
public function __construct(array $loggers = []) | ||
{ | ||
$this->loggers = $loggers; | ||
} | ||
|
||
/** @inheritdoc */ | ||
public function startQuery(string $sql, array $params = []) : void | ||
{ | ||
foreach ($this->loggers as $logger) { | ||
$logger->startQuery($sql, $params); | ||
} | ||
} | ||
|
||
public function stopQuery() : void | ||
{ | ||
foreach ($this->loggers as $logger) { | ||
$logger->stopQuery(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimPod\ClickHouseClient\Logger; | ||
|
||
use Psr\Log\LoggerInterface; | ||
|
||
final class PsrLogger implements SqlLogger | ||
{ | ||
private LoggerInterface $logger; | ||
|
||
public function __construct(LoggerInterface $logger) | ||
{ | ||
$this->logger = $logger; | ||
} | ||
|
||
/** @inheritdoc */ | ||
public function startQuery(string $sql, array $params = []) : void | ||
{ | ||
$this->logger->debug($sql, $params); | ||
} | ||
|
||
public function stopQuery() : void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimPod\ClickHouseClient\Logger; | ||
|
||
interface SqlLogger | ||
{ | ||
/** @param array<string, mixed> $params */ | ||
public function startQuery(string $sql, array $params = []) : void; | ||
|
||
public function stopQuery() : void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters