Skip to content

Commit

Permalink
LogLevel:MINIMAL, :MAXIMAL
Browse files Browse the repository at this point in the history
+ Some phpdoc updates.
  • Loading branch information
Trehinos committed Mar 21, 2023
1 parent 2fea12e commit ca0a6aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions thor/Database/PdoExtension/PdoRequester.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public function executeMultiple(string $sql, array $parameters, bool $continueIf
$result = true;

foreach ($parameters as $pdoRowsArray) {
Logger::writeDebug(' -> DB parameters', array_values($pdoRowsArray), LogLevel::INFO);
Logger::writeDebug(' -> DB parameters', array_values($pdoRowsArray), LogLevel::MINIMAL);
try {
$result = $result && $stmt->execute(array_values($pdoRowsArray));
} catch (PDOException $e) {
if (!Thor::isDebug()) {
Logger::writeDebug(' -> DB parameters', array_values($pdoRowsArray), LogLevel::WARNING);
}
Logger::logThrowable($e);
Logger::writeDebug(' -> DB execution failed : ', array_values($pdoRowsArray), LogLevel::ERROR);
Logger::logThrowable($e);
if (!$continueIfError) {
throw $e;
}
Expand Down Expand Up @@ -97,13 +97,20 @@ public function request(string $sql, array $parameters = []): PDOStatement
}

/**
* Gets the PdoHandler of this requester.
* Returns this instance's PDO connection handler.
*/
final public function getPdoHandler(): PdoHandler
{
return $this->handler;
}

/**
* Format a string like "(?, ?, ?, ...)" where number of '?' is `count($elements)`
*
* @param array $elements
*
* @return string
*/
public static function in(array $elements) : string
{
return '(' . implode(',', array_fill(0, count($elements), '?')) . ')';
Expand Down
4 changes: 4 additions & 0 deletions thor/Debug/LogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ enum LogLevel: int
case ALERT = 6;
case EMERGENCY = 7;

public const MINIMAL = self::INFO;

public const MAXIMAL = self::EMERGENCY;

/**
* Returns **minimum** LogLevel according to Env :
* - DEV --> INFO
Expand Down
2 changes: 1 addition & 1 deletion thor/Stream/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Stream implements StreamInterface
private const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';

/**
* @param resource
* @param resource $stream
* @param array $options
*
* @throws InvalidArgumentException
Expand Down

0 comments on commit ca0a6aa

Please sign in to comment.