Documentation

SocketHandler extends AbstractProcessingHandler
in package

Stores to any socket - uses fsockopen() or pfsockopen().

Tags
author

Pablo de Leon Belloc pablolb@gmail.com

see
http://php.net/manual/en/function.fsockopen.php

Table of Contents

Properties

$bubble  : mixed
$formatter  : FormatterInterface
$level  : mixed
$processors  : mixed
$chunkSize  : mixed
$connectionString  : mixed
$connectionTimeout  : mixed
$errno  : mixed
$errstr  : mixed
$lastSentBytes  : mixed
$lastWritingAt  : mixed
$persistent  : mixed
$resource  : mixed
$timeout  : mixed
$writingTimeout  : mixed

Methods

__construct()  : mixed
__destruct()  : mixed
close()  : mixed
We will not close a PersistentSocket instance so it can be reused in other requests.
closeSocket()  : mixed
Close socket, if open
getBubble()  : bool
Gets the bubbling behavior.
getChunkSize()  : float
Get current chunk size
getConnectionString()  : string
Get current connection string
getConnectionTimeout()  : float
Get current connection timeout setting
getFormatter()  : FormatterInterface
Gets the formatter.
getLevel()  : int
Gets minimum logging level at which this handler will be triggered.
getTimeout()  : float
Get current in-transfer timeout
getWritingTimeout()  : float
Get current local writing timeout
handle()  : bool
Handles a record.
handleBatch()  : mixed
Handles a set of records at once.
isConnected()  : bool
Check to see if the socket is currently available.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
isPersistent()  : bool
Get persistent setting
popProcessor()  : callable
Removes the processor on top of the stack and returns it.
pushProcessor()  : self
Adds a processor in the stack.
reset()  : mixed
setBubble()  : self
Sets the bubbling behavior.
setChunkSize()  : mixed
Set chunk size. Only has effect during connection in the writing cycle.
setConnectionTimeout()  : mixed
Set connection timeout. Only has effect before we connect.
setFormatter()  : self
Sets the formatter.
setLevel()  : self
Sets minimum logging level at which this handler will be triggered.
setPersistent()  : mixed
Set socket connection to nbe persistent. It only has effect before the connection is initiated.
setTimeout()  : mixed
Set write timeout. Only has effect before we connect.
setWritingTimeout()  : mixed
Set writing timeout. Only has effect during connection in the writing cycle.
fsockopen()  : mixed
Wrapper to allow mocking
fwrite()  : mixed
Wrapper to allow mocking
generateDataStream()  : mixed
getDefaultFormatter()  : FormatterInterface
Gets the default formatter.
getResource()  : resource|null
pfsockopen()  : mixed
Wrapper to allow mocking
processRecord()  : array<string|int, mixed>
Processes a record.
streamGetMetadata()  : mixed
Wrapper to allow mocking
streamSetChunkSize()  : mixed
Wrapper to allow mocking
streamSetTimeout()  : mixed
Wrapper to allow mocking
write()  : void
Connect (if necessary) and write to the socket
connect()  : mixed
connectIfNotConnected()  : mixed
createSocketResource()  : mixed
setSocketTimeout()  : mixed
setStreamChunkSize()  : mixed
validateTimeout()  : mixed
writeToSocket()  : mixed
writingIsTimedOut()  : mixed

Properties

Methods

__construct()

public __construct(string $connectionString[, int $level = Logger::DEBUG ][, bool $bubble = true ]) : mixed
Parameters
$connectionString : string

Socket connection string

$level : int = Logger::DEBUG

The minimum logging level at which this handler will be triggered

$bubble : bool = true

Whether the messages that are handled can bubble up the stack or not

close()

We will not close a PersistentSocket instance so it can be reused in other requests.

public close() : mixed

closeSocket()

Close socket, if open

public closeSocket() : mixed

getBubble()

Gets the bubbling behavior.

public getBubble() : bool
Return values
bool

true means that this handler allows bubbling. false means that bubbling is not permitted.

getChunkSize()

Get current chunk size

public getChunkSize() : float
Return values
float

getConnectionString()

Get current connection string

public getConnectionString() : string
Return values
string

getConnectionTimeout()

Get current connection timeout setting

public getConnectionTimeout() : float
Return values
float

getLevel()

Gets minimum logging level at which this handler will be triggered.

public getLevel() : int
Return values
int

getTimeout()

Get current in-transfer timeout

public getTimeout() : float
Return values
float

getWritingTimeout()

Get current local writing timeout

public getWritingTimeout() : float
Return values
float

handle()

Handles a record.

public handle(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

The record to handle

Return values
bool

true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.

handleBatch()

Handles a set of records at once.

public handleBatch(array<string|int, mixed> $records) : mixed
Parameters
$records : array<string|int, mixed>

The records to handle (an array of record arrays)

isConnected()

Check to see if the socket is currently available.

public isConnected() : bool

UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details.

Return values
bool

isHandling()

Checks whether the given record will be handled by this handler.

public isHandling(array<string|int, mixed> $record) : bool
Parameters
$record : array<string|int, mixed>

Partial log record containing only a level key

Return values
bool

isPersistent()

Get persistent setting

public isPersistent() : bool
Return values
bool

popProcessor()

Removes the processor on top of the stack and returns it.

public popProcessor() : callable
Return values
callable

pushProcessor()

Adds a processor in the stack.

public pushProcessor(mixed $callback) : self
Parameters
$callback : mixed
Return values
self

setBubble()

Sets the bubbling behavior.

public setBubble(bool $bubble) : self
Parameters
$bubble : bool

true means that this handler allows bubbling. false means that bubbling is not permitted.

Return values
self

setChunkSize()

Set chunk size. Only has effect during connection in the writing cycle.

public setChunkSize(float $bytes) : mixed
Parameters
$bytes : float

setLevel()

Sets minimum logging level at which this handler will be triggered.

public setLevel(int|string $level) : self
Parameters
$level : int|string

Level or level name

Return values
self

setPersistent()

Set socket connection to nbe persistent. It only has effect before the connection is initiated.

public setPersistent(bool $persistent) : mixed
Parameters
$persistent : bool

setWritingTimeout()

Set writing timeout. Only has effect during connection in the writing cycle.

public setWritingTimeout(float $seconds) : mixed
Parameters
$seconds : float

0 for no timeout

fsockopen()

Wrapper to allow mocking

protected fsockopen() : mixed

fwrite()

Wrapper to allow mocking

protected fwrite(mixed $data) : mixed
Parameters
$data : mixed

generateDataStream()

protected generateDataStream(mixed $record) : mixed
Parameters
$record : mixed

getResource()

protected getResource() : resource|null
Return values
resource|null

pfsockopen()

Wrapper to allow mocking

protected pfsockopen() : mixed

processRecord()

Processes a record.

protected processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Return values
array<string|int, mixed>

streamGetMetadata()

Wrapper to allow mocking

protected streamGetMetadata() : mixed

write()

Connect (if necessary) and write to the socket

protected write(array<string|int, mixed> $record) : void
Parameters
$record : array<string|int, mixed>
Tags
throws
UnexpectedValueException
throws
RuntimeException

connectIfNotConnected()

private connectIfNotConnected() : mixed

createSocketResource()

private createSocketResource() : mixed

validateTimeout()

private validateTimeout(mixed $value) : mixed
Parameters
$value : mixed

writeToSocket()

private writeToSocket(mixed $data) : mixed
Parameters
$data : mixed

writingIsTimedOut()

private writingIsTimedOut(mixed $sent) : mixed
Parameters
$sent : mixed

        
On this page

Search results