Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New StreamLogger & MultiLogger #556

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
060461b
removed PHP 7 stuff
dg Oct 12, 2022
b77a2f6
removed support for Nette __toString workaround
dg Dec 10, 2021
2b136ad
removed support for $context in error handler
dg Apr 22, 2022
ebe8fd4
removed FireLogger (BC break)
dg Dec 15, 2021
d83c812
updated tests
dg Dec 10, 2021
d149ed2
coding style
dg Mar 8, 2023
31ee43e
coding style: reformatted Assert::exception
dg Apr 7, 2022
10ad9b3
added property typehints
dg Feb 3, 2022
df64c19
added PHP 8 typehints
dg Dec 16, 2021
8fd56c0
used constructor promotion
dg Mar 2, 2023
ec5276c
Dumper: added ArrayIterator exposer
dg May 9, 2022
905c3d0
used native PHP 8 features
dg Dec 12, 2021
f4c3cbc
CSP: requires 'script-dynamic'
dg May 6, 2022
ae32c0f
Debugger::timer: switch from microtime to hrtime
bckp Jan 1, 2022
df85dcb
BlueScreen: added support for sensitive markers /*sensitive{*/ and /*…
dg Feb 27, 2023
960e86c
Describer::addPropertyTo() added $described
dg Mar 7, 2023
1363c82
Dumper: added support for enum/flags properties
dg Mar 7, 2023
d97a773
BlueScreen: simplified HTML comment escaping
dg Mar 8, 2023
c50307f
BlueScreen: added source to header
dg Mar 8, 2023
f875221
Released version 2.10.0
dg Feb 28, 2023
5788ef0
opened 3.0-dev
dg Dec 10, 2021
c358afd
uses PascalCase constants
dg Dec 5, 2022
4fd42f8
readme: added PSR3 adapter for monolog/monolog example
paxperscientiam Mar 20, 2022
133f8c9
removed bridge for Latte
dg Dec 20, 2021
22f4af8
Logger: added typehints
dg Feb 3, 2022
02641ee
shadow dom for dumper [WIP]
dg May 31, 2022
93c74fc
shadow dom for bar [WIP]
dg Jun 1, 2022
f2464fd
shadow dom for bluescreen [WIP]
dg Nov 18, 2022
1ac7a0a
Logger: add StreamLogger
f3l1x Mar 8, 2023
60d4fa8
Logger: add MultiLogger
f3l1x Mar 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Logger: added typehints
dg committed Mar 8, 2023
commit 22f4af82341e268b7bd9a074ae581fead0ae6b8d
37 changes: 13 additions & 24 deletions src/Tracy/Logger/Logger.php
Original file line number Diff line number Diff line change
@@ -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)
@@ -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) {
@@ -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]'),
@@ -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
@@ -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(