mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 05:07:36 +02:00
Codereview fixes based on @stof comments
This commit is contained in:
committed by
Haralan Dobrev
parent
4ab8ed0a53
commit
01a2ac25a2
@@ -35,7 +35,7 @@ class SlackRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Slack channel (encoded ID or name)
|
* Slack channel (encoded ID or name)
|
||||||
* @var string
|
* @var string|null
|
||||||
*/
|
*/
|
||||||
private $channel;
|
private $channel;
|
||||||
|
|
||||||
@@ -79,15 +79,8 @@ class SlackRecord
|
|||||||
*/
|
*/
|
||||||
private $lineFormatter;
|
private $lineFormatter;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct($channel = null, $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeContextAndExtra = false, FormatterInterface $formatter = null)
|
||||||
$channel,
|
{
|
||||||
$username = 'Monolog',
|
|
||||||
$useAttachment = true,
|
|
||||||
$iconEmoji = null,
|
|
||||||
$useShortAttachment = false,
|
|
||||||
$includeContextAndExtra = false,
|
|
||||||
FormatterInterface $formatter = null
|
|
||||||
) {
|
|
||||||
$this->channel = $channel;
|
$this->channel = $channel;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->iconEmoji = trim($iconEmoji, ':');
|
$this->iconEmoji = trim($iconEmoji, ':');
|
||||||
@@ -145,7 +138,7 @@ class SlackRecord
|
|||||||
$attachment['fields'][] = array(
|
$attachment['fields'][] = array(
|
||||||
'title' => "Extra",
|
'title' => "Extra",
|
||||||
'value' => $this->stringify($record['extra']),
|
'value' => $this->stringify($record['extra']),
|
||||||
'short' => $this->useShortAttachment,
|
'short' => true,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Add all extra fields as individual fields in attachment
|
// Add all extra fields as individual fields in attachment
|
||||||
@@ -153,7 +146,7 @@ class SlackRecord
|
|||||||
$attachment['fields'][] = array(
|
$attachment['fields'][] = array(
|
||||||
'title' => $var,
|
'title' => $var,
|
||||||
'value' => is_array($val) ? $this->lineFormatter->stringify($val) : $val,
|
'value' => is_array($val) ? $this->lineFormatter->stringify($val) : $val,
|
||||||
'short' => $this->useShortAttachment,
|
'short' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +157,7 @@ class SlackRecord
|
|||||||
$attachment['fields'][] = array(
|
$attachment['fields'][] = array(
|
||||||
'title' => "Context",
|
'title' => "Context",
|
||||||
'value' => $this->stringify($record['context']),
|
'value' => $this->stringify($record['context']),
|
||||||
'short' => $this->useShortAttachment,
|
'short' => true,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Add all context fields as individual fields in attachment
|
// Add all context fields as individual fields in attachment
|
||||||
@@ -172,7 +165,7 @@ class SlackRecord
|
|||||||
$attachment['fields'][] = array(
|
$attachment['fields'][] = array(
|
||||||
'title' => $var,
|
'title' => $var,
|
||||||
'value' => is_array($val) ? $this->lineFormatter->stringify($val) : $val,
|
'value' => is_array($val) ? $this->lineFormatter->stringify($val) : $val,
|
||||||
'short' => $this->useShortAttachment,
|
'short' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,21 +46,10 @@ class SlackHandler extends SocketHandler
|
|||||||
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data
|
* @param bool $includeContextAndExtra Whether the attachment should include context and extra data
|
||||||
* @throws MissingExtensionException If no OpenSSL PHP extension configured
|
* @throws MissingExtensionException If no OpenSSL PHP extension configured
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct($token, $channel, $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $level = Logger::CRITICAL, $bubble = true, $useShortAttachment = false, $includeContextAndExtra = false)
|
||||||
$token,
|
{
|
||||||
$channel,
|
|
||||||
$username = 'Monolog',
|
|
||||||
$useAttachment = true,
|
|
||||||
$iconEmoji = null,
|
|
||||||
$level = Logger::CRITICAL,
|
|
||||||
$bubble = true,
|
|
||||||
$useShortAttachment = false,
|
|
||||||
$includeContextAndExtra = false
|
|
||||||
) {
|
|
||||||
if (!extension_loaded('openssl')) {
|
if (!extension_loaded('openssl')) {
|
||||||
throw new MissingExtensionException(
|
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
|
||||||
'The OpenSSL PHP extension is required to use the SlackHandler'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct('ssl://slack.com:443', $level, $bubble);
|
parent::__construct('ssl://slack.com:443', $level, $bubble);
|
||||||
|
@@ -40,10 +40,11 @@ class SlackbotHandler extends AbstractProcessingHandler
|
|||||||
private $channel;
|
private $channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $token Slackbot token
|
* @param string $slackTeam Slack team slug
|
||||||
* @param string $channel Slack channel (encoded ID or name)
|
* @param string $token Slackbot token
|
||||||
* @param int $level The minimum logging level at which this handler will be triggered
|
* @param string $channel Slack channel (encoded ID or name)
|
||||||
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param int $level The minimum logging level at which this handler will be triggered
|
||||||
|
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$slackTeam,
|
$slackTeam,
|
||||||
|
Reference in New Issue
Block a user