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
Table of Contents
Constants
- FLEEP_HOOK_URI = '/hook/'
- FLEEP_HOST = 'fleep.io'
Properties
- $bubble : bool
- $formatter : FormatterInterface|null
- $level : Level
- $processors : array<string|int, callable>
- $token : string
Methods
- __construct() : mixed
- Construct a new Fleep.io Handler.
- __destruct() : mixed
- __sleep() : mixed
- close() : void
- We will not close a PersistentSocket instance so it can be reused in other requests.
- 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
- getLevel() : Level
- 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() : void
- 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
- pushProcessor() : HandlerInterface
- reset() : void
- setBubble() : $this
- Sets the bubbling behavior.
- setChunkSize() : $this
- Set chunk size. Only has effect during connection in the writing cycle.
- setConnectionTimeout() : $this
- Set connection timeout. Only has effect before we connect.
- setFormatter() : HandlerInterface
- setLevel() : $this
- Sets minimum logging level at which this handler will be triggered.
- setPersistent() : $this
- Set socket connection to be persistent. It only has effect before the connection is initiated.
- setTimeout() : $this
- Set write timeout. Only has effect before we connect.
- setWritingTimeout() : $this
- 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|false
- 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() : LogRecord
- resetProcessors() : void
- streamGetMetadata() : array<string|int, mixed>|bool
- Wrapper to allow mocking
- streamSetChunkSize() : int|false
- 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
Constants
FLEEP_HOOK_URI
protected
mixed
FLEEP_HOOK_URI
= '/hook/'
FLEEP_HOST
protected
mixed
FLEEP_HOST
= 'fleep.io'
Properties
$bubble
protected
bool
$bubble
= true
$formatter
protected
FormatterInterface|null
$formatter
= null
$level
protected
Level
$level
= \Monolog\Level::Debug
$processors
protected
array<string|int, callable>
$processors
= []
Tags
$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 = Level::Debug ][, bool $bubble = true ][, bool $persistent = false ][, float $timeout = 0.0 ][, float $writingTimeout = 10.0 ][, float|null $connectionTimeout = null ][, int|null $chunkSize = null ]) : 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 = Level::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
- $persistent : bool = false
-
Flag to enable/disable persistent connections
- $timeout : float = 0.0
-
Socket timeout to wait until the request is being aborted
- $writingTimeout : float = 10.0
-
Socket timeout to wait until the request should've been sent/written
- $connectionTimeout : float|null = null
-
Socket connect timeout to wait until the connection should've been established
- $chunkSize : int|null = null
-
Sets the chunk size. Only has effect during connection in the writing cycle
Tags
__destruct()
public
__destruct() : mixed
__sleep()
public
__sleep() : mixed
close()
We will not close a PersistentSocket instance so it can be reused in other requests.
public
close() : void
closeSocket()
Close socket, if open
public
closeSocket() : 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|nullgetConnectionString()
Get current connection string
public
getConnectionString() : string
Return values
stringgetConnectionTimeout()
Get current connection timeout setting
public
getConnectionTimeout() : float
Return values
floatgetFormatter()
public
getFormatter() : FormatterInterface
Tags
Return values
FormatterInterfacegetLevel()
Gets minimum logging level at which this handler will be triggered.
public
getLevel() : Level
Return values
LevelgetTimeout()
Get current in-transfer timeout
public
getTimeout() : float
Return values
floatgetWritingTimeout()
Get current local writing timeout
public
getWritingTimeout() : float
Return values
floathandle()
Handles a record.
public
handle(LogRecord $record) : bool
Parameters
- $record : LogRecord
-
The record to handle
Tags
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) : void
Parameters
- $records : array<string|int, mixed>
-
The records to handle
Tags
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
boolisHandling()
Checks whether the given record will be handled by this handler.
public
isHandling(LogRecord $record) : bool
Parameters
- $record : LogRecord
-
Partial log record having only a level initialized
Tags
Return values
boolisPersistent()
Get persistent setting
public
isPersistent() : bool
Return values
boolpopProcessor()
public
popProcessor() : callable
Tags
Return values
callablepushProcessor()
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Tags
Return values
HandlerInterfacereset()
public
reset() : void
setBubble()
Sets the bubbling behavior.
public
setBubble(bool $bubble) : $this
Parameters
- $bubble : bool
-
true means that this handler allows bubbling. false means that bubbling is not permitted.
Return values
$thissetChunkSize()
Set chunk size. Only has effect during connection in the writing cycle.
public
setChunkSize(int $bytes) : $this
Parameters
- $bytes : int
Return values
$thissetConnectionTimeout()
Set connection timeout. Only has effect before we connect.
public
setConnectionTimeout(float $seconds) : $this
Parameters
- $seconds : float
Tags
Return values
$thissetFormatter()
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Tags
Return values
HandlerInterfacesetLevel()
Sets minimum logging level at which this handler will be triggered.
public
setLevel(Level|LogLevel::* $level) : $this
Parameters
- $level : Level|LogLevel::*
-
Level or level name
Tags
Return values
$thissetPersistent()
Set socket connection to be persistent. It only has effect before the connection is initiated.
public
setPersistent(bool $persistent) : $this
Parameters
- $persistent : bool
Return values
$thissetTimeout()
Set write timeout. Only has effect before we connect.
public
setTimeout(float $seconds) : $this
Parameters
- $seconds : float
Tags
Return values
$thissetWritingTimeout()
Set writing timeout. Only has effect during connection in the writing cycle.
public
setWritingTimeout(float $seconds) : $this
Parameters
- $seconds : float
-
0 for no timeout
Return values
$thiswrite()
Handles a log record
public
write(LogRecord $record) : void
Parameters
- $record : LogRecord
fsockopen()
Wrapper to allow mocking
protected
fsockopen() : resource|false
Return values
resource|falsefwrite()
Wrapper to allow mocking
protected
fwrite(string $data) : int|false
Parameters
- $data : string
Return values
int|falsegenerateDataStream()
protected
generateDataStream(LogRecord $record) : string
Parameters
- $record : LogRecord
Tags
Return values
stringgetDefaultFormatter()
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
LineFormattergetResource()
protected
getResource() : resource|null
Return values
resource|nullpfsockopen()
Wrapper to allow mocking
protected
pfsockopen() : resource|false
Return values
resource|falseprocessRecord()
protected
processRecord(LogRecord $record) : LogRecord
Parameters
- $record : LogRecord
Return values
LogRecordresetProcessors()
protected
resetProcessors() : void
streamGetMetadata()
Wrapper to allow mocking
protected
streamGetMetadata() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolstreamSetChunkSize()
Wrapper to allow mocking
protected
streamSetChunkSize() : int|false
Tags
Return values
int|falsestreamSetTimeout()
Wrapper to allow mocking
protected
streamSetTimeout() : bool
Tags
Return values
boolbuildContent()
Builds the body of API call
private
buildContent(LogRecord $record) : string
Parameters
- $record : LogRecord
Return values
stringbuildHeader()
Builds the header of the API Call
private
buildHeader(string $content) : string
Parameters
- $content : string