mediatekformation

FleepHookHandler extends SocketHandler
in package

Sends logs to Fleep.io using Webhook integrations

You'll need a Fleep.io account to use this handler.

Tags
see
https://fleep.io/integrations/webhooks/

Fleep Webhooks Documentation

author

Ando Roots ando@sqroot.eu

phpstan-import-type

FormattedRecord from AbstractProcessingHandler

Table of Contents

FLEEP_HOOK_URI  = '/hook/'
FLEEP_HOST  = 'fleep.io'
$bubble  : bool
$formatter  : FormatterInterface|null
$level  : int
$processors  : array<string|int, callable>
$token  : string
$chunkSize  : int|null
$connectionString  : string
$connectionTimeout  : float
$errno  : int|null
$errstr  : string|null
$lastSentBytes  : int|null
$lastWritingAt  : float|null
$persistent  : bool
$resource  : resource|null
$timeout  : float
$writingTimeout  : float
__construct()  : mixed
Construct a new Fleep.io Handler.
__destruct()  : mixed
__sleep()  : mixed
close()  : void
Closes the handler.
closeSocket()  : void
Close socket, if open
getBubble()  : bool
Gets the bubbling behavior.
getChunkSize()  : int|null
Get current chunk size
getConnectionString()  : string
Get current connection string
getConnectionTimeout()  : float
Get current connection timeout setting
getFormatter()  : FormatterInterface
{@inheritDoc}
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
{@inheritDoc}
handleBatch()  : void
Handles a set of records at once.
isConnected()  : bool
Check to see if the socket is currently available.
isHandling()  : bool
{@inheritDoc}
isPersistent()  : bool
Get persistent setting
popProcessor()  : callable
{@inheritDoc}
pushProcessor()  : HandlerInterface
{@inheritDoc}
reset()  : void
setBubble()  : self
Sets the bubbling behavior.
setChunkSize()  : self
Set chunk size. Only has effect during connection in the writing cycle.
setConnectionTimeout()  : self
Set connection timeout. Only has effect before we connect.
setFormatter()  : HandlerInterface
{@inheritDoc}
setLevel()  : self
Sets minimum logging level at which this handler will be triggered.
setPersistent()  : self
Set socket connection to be persistent. It only has effect before the connection is initiated.
setTimeout()  : self
Set write timeout. Only has effect before we connect.
setWritingTimeout()  : self
Set writing timeout. Only has effect during connection in the writing cycle.
write()  : void
Handles a log record
fsockopen()  : resource|false
Wrapper to allow mocking
fwrite()  : int|bool
Wrapper to allow mocking
generateDataStream()  : string
getDefaultFormatter()  : LineFormatter
Returns the default formatter to use with this handler
getResource()  : resource|null
pfsockopen()  : resource|false
Wrapper to allow mocking
processRecord()  : array<string|int, mixed>
Processes a record.
resetProcessors()  : void
streamGetMetadata()  : array<string|int, mixed>|bool
Wrapper to allow mocking
streamSetChunkSize()  : int|bool
Wrapper to allow mocking
streamSetTimeout()  : bool
Wrapper to allow mocking
buildContent()  : string
Builds the body of API call
buildHeader()  : string
Builds the header of the API Call
connect()  : void
connectIfNotConnected()  : void
createSocketResource()  : void
setSocketTimeout()  : void
setStreamChunkSize()  : void
validateTimeout()  : void
writeToSocket()  : void
writingIsTimedOut()  : bool

Constants

Properties

$level

protected int $level = \Monolog\Logger::DEBUG
Tags
phpstan-var

Level

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<ProcessorInterface|callable(Record): Record>

$token

protected string $token

Webhook token (specifies the conversation where logs are sent)

Methods

__construct()

Construct a new Fleep.io Handler.

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

For instructions on how to create a new web hook in your conversations see https://fleep.io/integrations/webhooks/

Parameters
$token : string

Webhook token

$level : mixed = Logger::DEBUG
$bubble : bool = true
Tags
throws
MissingExtensionException
Return values
mixed —

__destruct()

public __destruct() : mixed
Return values
mixed —

__sleep()

public __sleep() : mixed
Return values
mixed —

close()

Closes the handler.

public close() : void
Return values
void —

closeSocket()

Close socket, if open

public closeSocket() : void
Return values
void —

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() : int|null
Return values
int|null —

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
Tags
phpstan-return

Level

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()

{@inheritDoc}

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

handleBatch()

Handles a set of records at once.

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

The records to handle (an array of record arrays)

Return values
void —

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()

{@inheritDoc}

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

isPersistent()

Get persistent setting

public isPersistent() : bool
Return values
bool —

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(int $bytes) : self
Parameters
$bytes : int
Return values
self —

setLevel()

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

public setLevel(mixed $level) : self
Parameters
$level : mixed
Return values
self —

setPersistent()

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

public setPersistent(bool $persistent) : self
Parameters
$persistent : bool
Return values
self —

setWritingTimeout()

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

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

0 for no timeout

Return values
self —

write()

Handles a log record

public write(array<string|int, mixed> $record) : void
Parameters
$record : array<string|int, mixed>
Return values
void —

fsockopen()

Wrapper to allow mocking

protected fsockopen() : resource|false
Return values
resource|false —

fwrite()

Wrapper to allow mocking

protected fwrite(string $data) : int|bool
Parameters
$data : string
Return values
int|bool —

generateDataStream()

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

getDefaultFormatter()

Returns the default formatter to use with this handler

protected getDefaultFormatter() : LineFormatter

Overloaded to remove empty context and extra arrays from the end of the log message.

Return values
LineFormatter —

getResource()

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

pfsockopen()

Wrapper to allow mocking

protected pfsockopen() : resource|false
Return values
resource|false —

processRecord()

Processes a record.

protected processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Tags
phpstan-param

Record $record

phpstan-return

Record

Return values
array<string|int, mixed> —

streamGetMetadata()

Wrapper to allow mocking

protected streamGetMetadata() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|bool —

buildContent()

Builds the body of API call

private buildContent(array<string|int, mixed> $record) : string
Parameters
$record : array<string|int, mixed>
Tags
phpstan-param

FormattedRecord $record

Return values
string —

buildHeader()

Builds the header of the API Call

private buildHeader(string $content) : string
Parameters
$content : string
Return values
string —

connectIfNotConnected()

private connectIfNotConnected() : void
Return values
void —

createSocketResource()

private createSocketResource() : void
Return values
void —

setSocketTimeout()

private setSocketTimeout() : void
Return values
void —

setStreamChunkSize()

private setStreamChunkSize() : void
Return values
void —

validateTimeout()

private validateTimeout(float $value) : void
Parameters
$value : float
Return values
void —

writeToSocket()

private writeToSocket(string $data) : void
Parameters
$data : string
Return values
void —

writingIsTimedOut()

private writingIsTimedOut(int $sent) : bool
Parameters
$sent : int
Return values
bool —

Search results