Skip to content

Commit

Permalink
still learning enums
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Apr 12, 2024
1 parent 4682225 commit acd54c5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Logger extends AbstractLogger
/** @var LoggerInterface */
protected LoggerInterface $actualLogger;

/** @var string */
protected string $breakLevel;
/** @var LogLevel */
protected LogLevel $breakLevel;

/**
* Logger constructor.
Expand All @@ -41,6 +41,10 @@ class Logger extends AbstractLogger
public function __construct(LoggerInterface $actualLogger, string|LogLevel $breakLevel = LogLevel::WARNING)
{
$this->actualLogger = $actualLogger;

if (is_string($breakLevel)) {
$breakLevel = LogLevel::from($breakLevel);
}
$this->breakLevel = $breakLevel;
}

Expand All @@ -49,7 +53,7 @@ public function __construct(LoggerInterface $actualLogger, string|LogLevel $brea
*/
public function startBreak(string|\Stringable $action): void
{
$this->log($this->breakLevel, substr(sprintf('%\'-5s Start %s %1$-\'-75s', '-', $action), 0, 75));
$this->log($this->breakLevel->value, substr(sprintf('%\'-5s Start %s %1$-\'-75s', '-', $action), 0, 75));
}

/**
Expand All @@ -67,6 +71,6 @@ public function log($level, string|\Stringable $message, array $context = array(
*/
public function endBreak(string|\Stringable $action): void
{
$this->log($this->breakLevel, substr(sprintf('%\'-5s End %s %1$-\'-75s', '-', $action), 0, 75));
$this->log($this->breakLevel->value, substr(sprintf('%\'-5s End %s %1$-\'-75s', '-', $action), 0, 75));
}
}

0 comments on commit acd54c5

Please sign in to comment.