101 throw new \InvalidArgumentException(
'The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.');
138 'notify' => $this->version == self::API_V1 ?
139 ($this->notify ? 1 : 0) :
140 ($this->notify ?
'true' :
'false'),
141 'message' => $record[
'formatted'],
142 'message_format' => $this->format,
147 if ($this->version == self::API_V1) {
152 return http_build_query($dataArray);
163 if ($this->version == self::API_V1) {
164 $header =
"POST /v1/rooms/message?format=json&auth_token={$this->token} HTTP/1.1\r\n";
167 $room = rawurlencode($this->room);
168 $header =
"POST /v2/room/{$room}/notification?auth_token={$this->token} HTTP/1.1\r\n";
171 $header .=
"Host: {$this->host}\r\n";
172 $header .=
"Content-Type: application/x-www-form-urlencoded\r\n";
173 $header .=
"Content-Length: " . strlen($content) .
"\r\n";
206 protected function write(array $record)
208 parent::write($record);
217 if (count($records) == 0) {
224 foreach ($batchRecords as $batchRecord) {
226 $this->
write($batchRecord);
249 $batchRecords = array();
251 $formattedMessages = array();
259 if ($record[
'level'] >
$level) {
260 $level = $record[
'level'];
261 $levelName = $record[
'level_name'];
264 if (null === $datetime) {
265 $datetime = $record[
'datetime'];
269 $messageStr = implode(PHP_EOL,
$messages);
270 $formattedMessages[] = $this->
getFormatter()->format($record);
271 $formattedMessageStr = implode(
'', $formattedMessages);
273 $batchRecord = array(
274 'message' => $messageStr,
275 'formatted' => $formattedMessageStr,
276 'context' => array(),
283 $lastFormattedMessage = array_pop($formattedMessages);
284 $batchRecord[
'message'] = implode(PHP_EOL,
$messages);
285 $batchRecord[
'formatted'] = implode(
'', $formattedMessages);
287 $batchRecords[] = $batchRecord;
289 $formattedMessages = array($lastFormattedMessage);
295 if (null !== $batchRecord) {
296 $batchRecords[] = $batchRecord;
300 foreach ($batchRecords as &$batchRecord) {
301 $batchRecord = array_merge(
305 'level_name' => $levelName,
306 'datetime' => $datetime
311 return $batchRecords;
331 if (function_exists(
'mb_strlen')) {
332 return (mb_strlen($str) <= $length);
335 return (strlen($str) <= $length);
const DEBUG
Detailed debug information.
const ERROR
Runtime errors.
Stores to any socket - uses fsockopen() or pfsockopen().
Sends notifications through the hipchat api to a hipchat room.
handleBatch(array $records)
{Handles a set of records at once.The records to handle (an array of record arrays)} ...
generateDataStream($record)
{}
const API_V2
Use API version v2.
const MAXIMUM_NAME_LENGTH
The maximum allowed length for the name used in the "from" field.
const MAXIMUM_MESSAGE_LENGTH
The maximum allowed length for the message.
getFormatter()
{Gets the formatter.FormatterInterface}
const WARNING
Exceptional occurrences that are not errors.
__construct($token, $room, $name='Monolog', $notify=false, $level=Logger::CRITICAL, $bubble=true, $useSSL=true, $format='text', $host='api.hipchat.com', $version=self::API_V1)
const CRITICAL
Critical conditions.
const API_V1
Use API version 1.
isHandling(array $record)
{Checks whether the given record will be handled by this handler.This is mostly done for performance ...
processRecord(array $record)
Processes a record.
buildHeader($content)
Builds the header of the API Call.
combineRecords($records)
Combines multiple records into one.
getAlertColor($level)
Assigns a color to each level of log records.
closeSocket()
Close socket, if open.
validateStringLength($str, $length)
Validates the length of a string.
buildContent($record)
Builds the body of API call.
const INFO
Interesting events.