ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\SlackbotHandler Class Reference

Sends notifications through Slack's Slackbot. More...

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

Public Member Functions

 __construct ($slackTeam, $token, $channel, $level=Logger::CRITICAL, $bubble=true)
 
- 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
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.
} 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
bool
} 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 ()
 
 reset ()
 

Protected Member Functions

 write (array $record)
 {} More...
 
- 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...
 

Private Attributes

 $slackTeam
 
 $token
 
 $channel
 

Additional Inherited Members

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

Detailed Description

Sends notifications through Slack's Slackbot.

Author
Haralan Dobrev hkdob.nosp@m.rev@.nosp@m.gmail.nosp@m..com
See also
https://slack.com/apps/A0F81R8ET-slackbot

Definition at line 22 of file SlackbotHandler.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\SlackbotHandler::__construct (   $slackTeam,
  $token,
  $channel,
  $level = Logger::CRITICAL,
  $bubble = true 
)
Parameters
string$slackTeamSlack team slug
string$tokenSlackbot token
string$channelSlack channel (encoded ID or name)
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

Definition at line 49 of file SlackbotHandler.php.

References Monolog\Handler\AbstractHandler\$bubble, Monolog\Handler\SlackbotHandler\$channel, Monolog\Handler\AbstractHandler\$level, Monolog\Handler\SlackbotHandler\$slackTeam, and Monolog\Handler\SlackbotHandler\$token.

Member Function Documentation

◆ write()

Monolog\Handler\SlackbotHandler::write ( array  $record)
protected

{}

Parameters
array$record

Definition at line 63 of file SlackbotHandler.php.

References Monolog\Handler\Curl\Util\execute().

64  {
65  $slackbotUrl = sprintf(
66  'https://%s.slack.com/services/hooks/slackbot?token=%s&channel=%s',
67  $this->slackTeam,
68  $this->token,
69  $this->channel
70  );
71 
72  $ch = curl_init();
73  curl_setopt($ch, CURLOPT_URL, $slackbotUrl);
74  curl_setopt($ch, CURLOPT_POST, true);
75  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
76  curl_setopt($ch, CURLOPT_POSTFIELDS, $record['message']);
77 
78  Curl\Util::execute($ch);
79  }
static execute($ch, $retries=5, $closeAfterDone=true)
Executes a CURL request with optional retries and exception on failure.
Definition: Util.php:32
+ Here is the call graph for this function:

Field Documentation

◆ $channel

Monolog\Handler\SlackbotHandler::$channel
private

Definition at line 40 of file SlackbotHandler.php.

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

◆ $slackTeam

Monolog\Handler\SlackbotHandler::$slackTeam
private

Definition at line 28 of file SlackbotHandler.php.

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

◆ $token

Monolog\Handler\SlackbotHandler::$token
private

Definition at line 34 of file SlackbotHandler.php.

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


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