Skip to content

Commit 5dd089d

Browse files
committed
Ensure each logged line ends with a new line
1 parent 3e0ded7 commit 5dd089d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/Connection/ImapConnection.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,11 @@ public function send(string $name, array $tokens = [], ?string &$tag = null): vo
574574
*/
575575
protected function write(string $data): void
576576
{
577-
$command = $data."\r\n";
578-
579-
$this->logger?->sent($command);
580-
581-
if ($this->stream->fwrite($command) === false) {
577+
if ($this->stream->fwrite($data."\r\n") === false) {
582578
throw new RuntimeException('Failed to write data to stream.');
583579
}
580+
581+
$this->logger?->sent($data);
584582
}
585583

586584
/**

src/Connection/Loggers/Logger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ abstract protected function write(string $message): void;
1414
*/
1515
public function sent(string $message): void
1616
{
17-
$this->write(sprintf('>> %s: %s', $this->date(), $message));
17+
$this->write(sprintf('%s: >> %s', $this->date(), $message).PHP_EOL);
1818
}
1919

2020
/**
2121
* {@inheritDoc}
2222
*/
2323
public function received(string $message): void
2424
{
25-
$this->write(sprintf('<< %s: %s', $this->date(), $message));
25+
$this->write(sprintf('%s: << %s', $this->date(), $message).PHP_EOL);
2626
}
2727

2828
/**

0 commit comments

Comments
 (0)