-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
13 changed files
with
367 additions
and
62 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
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Logger\Context; | ||
|
||
use Throwable; | ||
use Yiisoft\Db\Logger\ContextInterface; | ||
|
||
abstract class AbstractContext implements ContextInterface | ||
{ | ||
private Throwable|null $exception = null; | ||
|
||
public function __construct(private string $methodName) | ||
{ | ||
} | ||
|
||
public function getMethodName(): string | ||
{ | ||
return $this->methodName; | ||
} | ||
|
||
public function setException(Throwable $e): static | ||
{ | ||
$this->exception = $e; | ||
return $this; | ||
} | ||
|
||
public function getException(): Throwable|null | ||
{ | ||
return $this->exception; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Logger\Context; | ||
|
||
final class ConnectionContext extends AbstractContext | ||
{ | ||
public function __construct(string $methodName, private string $dsn) | ||
{ | ||
parent::__construct($methodName); | ||
} | ||
|
||
public function getDsn(): string | ||
{ | ||
return $this->dsn; | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Logger\Context; | ||
|
||
final class QueryContext extends AbstractContext | ||
{ | ||
public function __construct(string $methodName, private string $rawSql, private string $category) | ||
{ | ||
parent::__construct($methodName); | ||
} | ||
|
||
public function getRawSql(): string | ||
{ | ||
return $this->rawSql; | ||
} | ||
|
||
public function getCategory(): string | ||
{ | ||
return $this->category; | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Logger\Context; | ||
|
||
final class TransactionContext extends AbstractContext | ||
{ | ||
public function __construct(string $methodName, private int $level, private string|null $isolationLevel = null) | ||
{ | ||
parent::__construct($methodName); | ||
} | ||
|
||
public function getLevel(): int | ||
{ | ||
return $this->level; | ||
} | ||
|
||
public function getIsolationLevel(): string|null | ||
{ | ||
return $this->isolationLevel; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Logger; | ||
|
||
use Throwable; | ||
|
||
/** | ||
* Logger context. | ||
*/ | ||
interface ContextInterface | ||
{ | ||
public function getMethodName(): string; | ||
|
||
public function getException(): Throwable|null; | ||
public function setException(Throwable $e): static; | ||
} |
Oops, something went wrong.