mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-18 10:51:19 +02:00
Rewriting the write method
Before, the write method would alter the $record array and then call parent::write(). Now the method builds the string which should be written into the stream and then does it himself. I had to change two methods to be protected so the PushoverHandler could call them.
This commit is contained in:
@@ -36,7 +36,7 @@ class PushoverHandler extends SocketHandler
|
||||
{
|
||||
parent::__construct('api.pushover.net', $level, $bubble);
|
||||
$this->conntectionPort = 80;
|
||||
|
||||
|
||||
$this->token = $token;
|
||||
$this->user = $user;
|
||||
$this->title = $title;
|
||||
@@ -55,9 +55,9 @@ class PushoverHandler extends SocketHandler
|
||||
{
|
||||
$data = $this->buildDataString($record);
|
||||
$content = $this->buildContent($data);
|
||||
$record['formatted'] = $content;
|
||||
|
||||
parent::write($record);
|
||||
$this->connectIfNotConnected();
|
||||
$this->writeToSocket($content);
|
||||
}
|
||||
|
||||
private function buildContent($data)
|
||||
|
@@ -219,7 +219,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
}
|
||||
}
|
||||
|
||||
private function connectIfNotConnected()
|
||||
protected function connectIfNotConnected()
|
||||
{
|
||||
if ($this->isConnected()) {
|
||||
return;
|
||||
@@ -253,7 +253,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
}
|
||||
}
|
||||
|
||||
private function writeToSocket($data)
|
||||
protected function writeToSocket($data)
|
||||
{
|
||||
$length = strlen($data);
|
||||
$sent = 0;
|
||||
|
Reference in New Issue
Block a user