Skip to content

Commit

Permalink
Logger: added typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 29, 2023
1 parent 1a1be93 commit 6273fec
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/Tracy/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
*/
class Logger implements ILogger
{
/** @var string|null name of the directory where errors should be logged */
public $directory;
/** name of the directory where errors should be logged */
public ?string $directory = null;

/** @var string|array|null email or emails to which send error notifications */
public $email;
/** email or emails to which send error notifications */
public string|array|null $email = null;

/** @var string|null sender of email notifications */
public $fromEmail;
/** sender of email notifications */
public ?string $fromEmail = null;

/** @var mixed interval for sending email is 2 days */
public $emailSnooze = '2 days';
/** interval for sending email is 2 days */
public mixed $emailSnooze = '2 days';

/** @var callable handler for sending emails */
public $mailer;

/** @var BlueScreen|null */
private $blueScreen;
private ?BlueScreen $blueScreen = null;


public function __construct(?string $directory, string|array|null $email = null, ?BlueScreen $blueScreen = null)
Expand Down Expand Up @@ -78,10 +77,7 @@ public function log(mixed $message, string $level = self::INFO)
}


/**
* @param mixed $message
*/
public static function formatMessage($message): string
public static function formatMessage(mixed $message): string
{
if ($message instanceof \Throwable) {
foreach (Helpers::getExceptionChain($message) as $exception) {
Expand All @@ -101,10 +97,7 @@ public static function formatMessage($message): string
}


/**
* @param mixed $message
*/
public static function formatLogLine($message, ?string $exceptionFile = null): string
public static function formatLogLine(mixed $message, ?string $exceptionFile = null): string
{
return implode(' ', [
date('[Y-m-d H-i-s]'),
Expand Down Expand Up @@ -152,10 +145,7 @@ protected function logException(\Throwable $exception, ?string $file = null): st
}


/**
* @param mixed $message
*/
protected function sendEmail($message): void
protected function sendEmail(mixed $message): void
{
$snooze = is_numeric($this->emailSnooze)
? $this->emailSnooze
Expand All @@ -174,10 +164,9 @@ protected function sendEmail($message): void

/**
* Default mailer.
* @param mixed $message
* @internal
*/
public function defaultMailer($message, string $email): void
public function defaultMailer(mixed $message, string $email): void
{
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n'));
$parts = str_replace(
Expand Down

0 comments on commit 6273fec

Please sign in to comment.