Plop
A simple logging library for PHP
|
An handler that sends log messages to a remote host over a TCP socket. More...
Public Member Functions | |
__construct ($host, $port) | |
__destruct () | |
Free the resources used by this handler. | |
getCloseOnError () | |
getInitialRetryDelay () | |
getMaximumRetryDelay () | |
getRetryFactor () | |
handleError (\Plop\RecordInterface $record,\Exception $exception) | |
setCloseOnError ($close) | |
setInitialRetryDelay ($delay) | |
setMaximumRetryDelay ($max) | |
setRetryFactor ($factor) | |
Public Member Functions inherited from Plop\HandlerAbstract | |
__construct (\Plop\FormatterInterface $formatter=null,\Plop\FiltersCollectionAbstract $filters=null) | |
getFilters () | |
getFormatter () | |
handle (\Plop\RecordInterface $record) | |
handleError (\Plop\RecordInterface $record,\Exception $exception) | |
setFilters (\Plop\FiltersCollectionAbstract $filters) | |
setFormatter (\Plop\FormatterInterface $formatter) | |
Protected Member Functions | |
close () | |
createSocket () | |
emit (\Plop\RecordInterface $record) | |
getCurrentTime () | |
makePickle (\Plop\RecordInterface $record) | |
makeSocket ($timeout=1) | |
send ($s) | |
write ($s) | |
Protected Member Functions inherited from Plop\HandlerAbstract | |
emit (\Plop\RecordInterface $record) | |
format (\Plop\RecordInterface $record) | |
getStderr () | |
Protected Attributes | |
$closeOnError | |
Whether to close the socket automatically on error. | |
$host | |
Remote host where the logs will be sent. | |
$port | |
Remote port where the logs will be sent. | |
$retryFactor | |
Factor applied to the reconnection delay after a reconnection failure. | |
$retryMax | |
Maximum delay between reconnection attempts. | |
$retryPeriod | |
The delay that will apply to the next reconnection attempt. | |
$retryStart | |
Initial delay for reconnection attempts. | |
$retryTime | |
UNIX timestamp of the next connection attempt, if any. | |
$socket | |
The socket that will be used to send the logs. | |
Protected Attributes inherited from Plop\HandlerAbstract | |
$filters | |
An object handling a collection of filters. | |
$formatter | |
Formatter object to use for this handler. | |
An handler that sends log messages to a remote host over a TCP socket.
Definition at line 28 of file Socket.php.
Plop\Handler\Socket::__construct | ( | $host, | |
$port | |||
) |
Construct a new instance of this handler.
string | $host | The remote host where the logs will be sent. This may be a (fully qualified) host name or an IP address (v4 or v6). |
int | $port | Destination port where the logs will be sent. |
Definition at line 68 of file Socket.php.
References Plop\Handler\Socket\$host, and Plop\Handler\Socket\$port.
|
protected |
Close the socket associated with this handler.
Definition at line 402 of file Socket.php.
Referenced by Plop\Handler\Socket\__destruct(), and Plop\Handler\Socket\handleError().
|
protected |
Create a new socket, taking into account things like retry attempts and delays.
Definition at line 267 of file Socket.php.
References Plop\Handler\Socket\$retryFactor, Plop\Handler\Socket\$retryMax, Plop\Handler\Socket\$retryPeriod, Plop\Handler\Socket\$retryStart, Plop\Handler\Socket\$retryTime, Plop\Handler\Socket\getCurrentTime(), and Plop\Handler\Socket\makeSocket().
Referenced by Plop\Handler\Socket\send().
|
protected |
Definition at line 386 of file Socket.php.
References Plop\Handler\Socket\handleError(), Plop\Handler\Socket\makePickle(), and Plop\Handler\Socket\send().
Plop\Handler\Socket::getCloseOnError | ( | ) |
Return whether the socket is closed automatically after an error.
bool | Whether the socket is closed automatically on error (true) or not (false). |
Definition at line 103 of file Socket.php.
References Plop\Handler\Socket\$closeOnError.
|
protected |
Return the current time as a UNIX timestamp.
int | The current time, as a UNIX timestamp. |
Definition at line 255 of file Socket.php.
Referenced by Plop\Handler\Socket\createSocket().
Plop\Handler\Socket::getInitialRetryDelay | ( | ) |
Return the delay for the initial reconnection attempt.
int|float | Initial delay for reconnection attempts. |
Definition at line 135 of file Socket.php.
References Plop\Handler\Socket\$retryStart.
Plop\Handler\Socket::getMaximumRetryDelay | ( | ) |
Return the maximum delay between reconnection attempts.
int|float | Maximum delay between reconnection attempts. |
Definition at line 199 of file Socket.php.
References Plop\Handler\Socket\$retryMax.
Plop\Handler\Socket::getRetryFactor | ( | ) |
Return the current delay factor between reconnection attempts.
int|float | Current delay factor. |
Definition at line 167 of file Socket.php.
References Plop\Handler\Socket\$retryFactor.
Plop\Handler\Socket::handleError | ( | \Plop\RecordInterface | $record, |
\Exception | $exception | ||
) |
Implements Plop\HandlerInterface.
Definition at line 375 of file Socket.php.
References Plop\Handler\Socket\close().
Referenced by Plop\Handler\Socket\emit().
|
protected |
Serialize and format a log record so that it can be sent through the wire.
Plop::RecordInterface | $record | The record to serialize. |
string | Serialized representation of the record, with additional metadata. |
Definition at line 363 of file Socket.php.
Referenced by Plop\Handler\Socket\emit().
|
protected |
Really create a new socket.
int | $timeout | (optional) Timeout for the connection, in seconds. Defaults to 1 second. |
resource | The newly created socket. |
Definition at line 236 of file Socket.php.
Referenced by Plop\Handler\Socket\createSocket().
|
protected |
Send the given string over the wire.
string | $s | The text to send over. |
bool | Whether a connection could be established and the data sent properly. |
Plop::Exception | The connection was lost during the transmission. |
Definition at line 310 of file Socket.php.
References Plop\Handler\Socket\createSocket(), and Plop\Handler\Socket\write().
Referenced by Plop\Handler\Socket\emit().
Plop\Handler\Socket::setCloseOnError | ( | $close | ) |
Set whether the socket must be closed automatically on error.
bool | $close | The socket will be closed on error if this is true. |
Plop::HandlerInterface | The current handler instance (ie. $this). |
Definition at line 119 of file Socket.php.
Plop\Handler\Socket::setInitialRetryDelay | ( | $delay | ) |
Set the delay for the initial reconnection attempt.
int | float | $delay | Initial delay for reconnection attempts. This value must be a non-negative number. |
Plop::HandlerInterface | The current handler instance (ie. $this). |
Definition at line 151 of file Socket.php.
Plop\Handler\Socket::setMaximumRetryDelay | ( | $max | ) |
Set the maximum delay between reconnection attempts.
int | float | $max | Maximum delay between reconnection attempts. This value must be a non-negative number. |
Plop::HandlerInterface | The current handler instance (ie. $this). |
Definition at line 215 of file Socket.php.
Plop\Handler\Socket::setRetryFactor | ( | $factor | ) |
Set the factor applied to the delay between each reconnection attempt.
int | float | $factor | Delay factor. This value must be greater or equal to 1. |
Plop::HandlerInterface | The current handler instance (ie. $this). |
Definition at line 183 of file Socket.php.
|
protected |
Write data to the underlying stream.
string | $s | Data to write. |
false|int | Return the number of bytes written to the underlying stream (which can be less than the length of the data given due to buffering) or false in case of an error (eg. connection lost). |
Definition at line 347 of file Socket.php.
Referenced by Plop\Handler\Socket\send().