ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Monolog\Handler\FleepHookHandler Class Reference

Sends logs to Fleep.io using Webhook integrations. More...

+ Inheritance diagram for Monolog\Handler\FleepHookHandler:
+ Collaboration diagram for Monolog\Handler\FleepHookHandler:

Public Member Functions

 __construct ($token, $level=Logger::DEBUG, $bubble=true)
 Construct a new Fleep.io Handler. More...
 
 write (array $record)
 Handles a log record. More...
 
- Public Member Functions inherited from Monolog\Handler\SocketHandler
 __construct ($connectionString, $level=Logger::DEBUG, $bubble=true)
 
 close ()
 We will not close a PersistentSocket instance so it can be reused in other requests. More...
 
 closeSocket ()
 Close socket, if open. More...
 
 setPersistent ($persistent)
 Set socket connection to nbe persistent. More...
 
 setConnectionTimeout ($seconds)
 Set connection timeout. More...
 
 setTimeout ($seconds)
 Set write timeout. More...
 
 setWritingTimeout ($seconds)
 Set writing timeout. More...
 
 getConnectionString ()
 Get current connection string. More...
 
 isPersistent ()
 Get persistent setting. More...
 
 getConnectionTimeout ()
 Get current connection timeout setting. More...
 
 getTimeout ()
 Get current in-transfer timeout. More...
 
 getWritingTimeout ()
 Get current local writing timeout. More...
 
 isConnected ()
 Check to see if the socket is currently available. More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 handle (array $record)
 {Handles a record.All records may be passed to this method, and the handler should discard those that it does not want to handle.The return value of this function controls the bubbling process of the handler stack. Unless the bubbling is interrupted (by returning true), the Logger class will keep on calling further handlers in the stack with a given log record.
Parameters
array$recordThe record to handle
Returns
Boolean 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.
} More...
 
- Public Member Functions inherited from Monolog\Handler\AbstractHandler
 __construct ($level=Logger::DEBUG, $bubble=true)
 
 isHandling (array $record)
 {Checks whether the given record will be handled by this handler.This is mostly done for performance reasons, to avoid calling processors for nothing.Handlers should still check the record levels within handle(), returning false in isHandling() is no guarantee that handle() will not be called, and isHandling() might not be called for a given record.
Parameters
array$recordPartial log record containing only a level key
Returns
Boolean
} More...
 
 handleBatch (array $records)
 {Handles a set of records at once.
Parameters
array$recordsThe records to handle (an array of record arrays)
} More...
 
 close ()
 Closes the handler. More...
 
 pushProcessor ($callback)
 {Adds a processor in the stack.
Parameters
callable$callback
Returns
self
} More...
 
 popProcessor ()
 {Removes the processor on top of the stack and returns it.
Returns
callable
} More...
 
 setFormatter (FormatterInterface $formatter)
 {Sets the formatter.
Parameters
FormatterInterface$formatter
Returns
self
} More...
 
 getFormatter ()
 {Gets the formatter.
Returns
FormatterInterface
} More...
 
 setLevel ($level)
 Sets minimum logging level at which this handler will be triggered. More...
 
 getLevel ()
 Gets minimum logging level at which this handler will be triggered. More...
 
 setBubble ($bubble)
 Sets the bubbling behavior. More...
 
 getBubble ()
 Gets the bubbling behavior. More...
 
 __destruct ()
 

Data Fields

const FLEEP_HOST = 'fleep.io'
 
const FLEEP_HOOK_URI = '/hook/'
 

Protected Member Functions

 getDefaultFormatter ()
 Returns the default formatter to use with this handler. More...
 
 generateDataStream ($record)
 {} More...
 
- Protected Member Functions inherited from Monolog\Handler\SocketHandler
 write (array $record)
 Connect (if necessary) and write to the socket. More...
 
 pfsockopen ()
 Wrapper to allow mocking. More...
 
 fsockopen ()
 Wrapper to allow mocking. More...
 
 streamSetTimeout ()
 Wrapper to allow mocking. More...
 
 fwrite ($data)
 Wrapper to allow mocking. More...
 
 streamGetMetadata ()
 Wrapper to allow mocking. More...
 
 generateDataStream ($record)
 
 getResource ()
 
- Protected Member Functions inherited from Monolog\Handler\AbstractProcessingHandler
 write (array $record)
 Writes the record down to the log of the implementing handler. More...
 
 processRecord (array $record)
 Processes a record. More...
 
- Protected Member Functions inherited from Monolog\Handler\AbstractHandler
 getDefaultFormatter ()
 Gets the default formatter. More...
 

Protected Attributes

 $token
 
- Protected Attributes inherited from Monolog\Handler\AbstractHandler
 $level = Logger::DEBUG
 
 $bubble = true
 
 $formatter
 
 $processors = array()
 

Private Member Functions

 buildHeader ($content)
 Builds the header of the API Call. More...
 
 buildContent ($record)
 Builds the body of API call. More...
 

Detailed Description

Sends logs to Fleep.io using Webhook integrations.

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

See also
https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation
Author
Ando Roots ando@.nosp@m.sqro.nosp@m.ot.eu

Definition at line 25 of file FleepHookHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\FleepHookHandler::__construct (   $token,
  $level = Logger::DEBUG,
  $bubble = true 
)

Construct a new Fleep.io Handler.

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

Parameters
string$tokenWebhook token
bool | int$levelThe minimum logging level at which this handler will be triggered
bool$bubbleWhether the messages that are handled can bubble up the stack or not
Exceptions
MissingExtensionException

Definition at line 47 of file FleepHookHandler.php.

References Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\SocketHandler\$connectionString, Monolog\Handler\AbstractHandler\$level, and Monolog\Handler\FleepHookHandler\$token.

48  {
49  if (!extension_loaded('openssl')) {
50  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler');
51  }
52 
53  $this->token = $token;
54 
55  $connectionString = 'ssl://' . self::FLEEP_HOST . ':443';
56  parent::__construct($connectionString, $level, $bubble);
57  }

Member Function Documentation

◆ buildContent()

Monolog\Handler\FleepHookHandler::buildContent (   $record)
private

Builds the body of API call.

Parameters
array$record
Returns
string

Definition at line 118 of file FleepHookHandler.php.

References $dataArray, and array.

Referenced by Monolog\Handler\FleepHookHandler\generateDataStream().

119  {
120  $dataArray = array(
121  'message' => $record['formatted'],
122  );
123 
124  return http_build_query($dataArray);
125  }
$dataArray
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ buildHeader()

Monolog\Handler\FleepHookHandler::buildHeader (   $content)
private

Builds the header of the API Call.

Parameters
string$content
Returns
string

Definition at line 101 of file FleepHookHandler.php.

References $header.

Referenced by Monolog\Handler\FleepHookHandler\generateDataStream().

102  {
103  $header = "POST " . self::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n";
104  $header .= "Host: " . self::FLEEP_HOST . "\r\n";
105  $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
106  $header .= "Content-Length: " . strlen($content) . "\r\n";
107  $header .= "\r\n";
108 
109  return $header;
110  }
$header
+ Here is the caller graph for this function:

◆ generateDataStream()

Monolog\Handler\FleepHookHandler::generateDataStream (   $record)
protected

{}

Parameters
array$record
Returns
string

Definition at line 88 of file FleepHookHandler.php.

References Monolog\Handler\FleepHookHandler\buildContent(), and Monolog\Handler\FleepHookHandler\buildHeader().

89  {
90  $content = $this->buildContent($record);
91 
92  return $this->buildHeader($content) . $content;
93  }
buildContent($record)
Builds the body of API call.
buildHeader($content)
Builds the header of the API Call.
+ Here is the call graph for this function:

◆ getDefaultFormatter()

Monolog\Handler\FleepHookHandler::getDefaultFormatter ( )
protected

Returns the default formatter to use with this handler.

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

Returns
LineFormatter

Definition at line 66 of file FleepHookHandler.php.

67  {
68  return new LineFormatter(null, null, true, true);
69  }

◆ write()

Monolog\Handler\FleepHookHandler::write ( array  $record)

Handles a log record.

Parameters
array$record

Definition at line 76 of file FleepHookHandler.php.

References Monolog\Handler\SocketHandler\closeSocket().

77  {
78  parent::write($record);
79  $this->closeSocket();
80  }
closeSocket()
Close socket, if open.
+ Here is the call graph for this function:

Field Documentation

◆ $token

Monolog\Handler\FleepHookHandler::$token
protected

Definition at line 34 of file FleepHookHandler.php.

Referenced by Monolog\Handler\FleepHookHandler\__construct().

◆ FLEEP_HOOK_URI

const Monolog\Handler\FleepHookHandler::FLEEP_HOOK_URI = '/hook/'

Definition at line 29 of file FleepHookHandler.php.

◆ FLEEP_HOST

const Monolog\Handler\FleepHookHandler::FLEEP_HOST = 'fleep.io'

The documentation for this class was generated from the following file: