Skip to content

Commit 416ca40

Browse files
committed
feature #53706 [Mailer] Add timestamp to SMTP debug log (bytestream)
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
2 parents 3477db8 + bfccafa commit 416ca40

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Transport/Smtp/Stream/AbstractStream.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ abstract class AbstractStream
3636
public function write(string $bytes, bool $debug = true): void
3737
{
3838
if ($debug) {
39+
$timestamp = date('c');
3940
foreach (explode("\n", trim($bytes)) as $line) {
40-
$this->debug .= sprintf("> %s\n", $line);
41+
$this->debug .= sprintf("[%s] > %s\n", $timestamp, $line);
4142
}
4243
}
4344

@@ -91,7 +92,7 @@ public function readLine(): string
9192
}
9293
}
9394

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

9697
return $line;
9798
}

0 commit comments

Comments
 (0)