Skip to content

Commit

Permalink
feature #53706 [Mailer] Add timestamp to SMTP debug log (bytestream)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 7.1 branch.

Discussion
----------

[Mailer] Add timestamp to SMTP debug log

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        |
| License       | MIT

When debugging #53647, the lack of a timestamp made it difficult to understand why the `RSET` was happening before a response had been received. The timestamps gave a clue towards the problem. The timestamps also help show slow connections which you're otherwise not aware of.

Commits
-------

53a637c381 [Mailer] Add timestamp to SMTP debug log
  • Loading branch information
fabpot committed Feb 4, 2024
2 parents 3477db8 + bfccafa commit 416ca40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Transport/Smtp/Stream/AbstractStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ abstract class AbstractStream
public function write(string $bytes, bool $debug = true): void
{
if ($debug) {
$timestamp = date('c');
foreach (explode("\n", trim($bytes)) as $line) {
$this->debug .= sprintf("> %s\n", $line);
$this->debug .= sprintf("[%s] > %s\n", $timestamp, $line);
}
}

Expand Down Expand Up @@ -91,7 +92,7 @@ public function readLine(): string
}
}

$this->debug .= sprintf('< %s', $line);
$this->debug .= sprintf('[%s] < %s', date('c'), $line);

return $line;
}
Expand Down

0 comments on commit 416ca40

Please sign in to comment.