本文整理汇总了PHP中Monolog\Handler\SocketHandler类的典型用法代码示例。如果您正苦于以下问题:PHP SocketHandler类的具体用法?PHP SocketHandler怎么用?PHP SocketHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SocketHandler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpNetworkLogs
/**
* @param Container $container
*
* @return void
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
protected static function setUpNetworkLogs(Container $container)
{
$container[LoggerInterface::class] = function (Container $container) {
$appConfig = $container->get(ConfigInterface::class)->getConfig(C::class);
$monolog = new Logger($appConfig[C::KEY_NAME]);
if ($appConfig[C::KEY_IS_LOG_ENABLED] === true) {
$handler = new SocketHandler('udp://localhost:8081', $appConfig[C::KEY_LOG_LEVEL]);
$handler->pushProcessor(new WebProcessor());
$handler->pushProcessor(new UidProcessor());
} else {
$handler = new NullHandler();
}
$monolog->pushHandler($handler);
return $monolog;
};
}
示例2: __construct
/**
* @param string $token Pushover api token
* @param string $user Pushover user id the message will be sent to
* @param string $title Title sent to Pushover API
* @param integer $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($token, $user, $title = null, $level = Logger::CRITICAL, $bubble = true)
{
parent::__construct('api.pushover.net:80', $level, $bubble);
$this->token = $token;
$this->user = $user;
$this->title = $title ?: gethostname();
}
示例3: __construct
/**
* @param string $token Log token supplied by LogEntries
* @param boolean $useSSL Whether or not SSL encryption should be used.
* @param int $level The minimum logging level to trigger this handler
* @param boolean $bubble Whether or not messages that are handled should bubble up the stack.
*
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
*/
public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true)
{
if ($useSSL && !extension_loaded('openssl')) {
throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
}
$endpoint = $useSSL ? 'ssl://data.logentries.com:443' : 'data.logentries.com:80';
parent::__construct($endpoint, $level, $bubble);
$this->logToken = $token;
}
示例4: write
public function write(array $record)
{
foreach ($this->users as $user) {
$this->user = $user;
parent::write($record);
$this->closeSocket();
}
$this->user = null;
}
示例5: __construct
/**
* @param string $token Log token supplied by Logmatic.
* @param string $hostname Host name supplied by Logmatic.
* @param string $appname Application name supplied by Logmatic.
* @param bool $useSSL Whether or not SSL encryption should be used.
* @param int|string $level The minimum logging level to trigger this handler.
* @param bool $bubble Whether or not messages that are handled should bubble up the stack.
*
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
*/
public function __construct(string $token, string $hostname = '', string $appname = '', bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true)
{
if ($useSSL && !extension_loaded('openssl')) {
throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler');
}
$endpoint = $useSSL ? 'ssl://api.logmatic.io:10515' : 'api.logmatic.io:10514';
$endpoint .= '/v1/';
parent::__construct($endpoint, $level, $bubble);
$this->logToken = $token;
$this->hostname = $hostname;
$this->appname = $appname;
}
示例6: processRecord
/**
* @param array $rawrecord
* @return array
*/
protected function processRecord(array $rawrecord)
{
$record = parent::processRecord($rawrecord);
$record['datetime'] = $record['datetime']->format(\DateTime::ISO8601);
if (empty($record['extra'])) {
unset($record['extra']);
}
if (isset($record['context'])) {
$context = $record['context'];
if (isset($context['exception'])) {
$record['exception'] = $this->parseException($context['exception']);
unset($record['context']['exception']);
}
}
if (empty($record['context'])) {
unset($record['context']);
}
if (!empty($record['level_name'])) {
$record['level'] = $record['level_name'];
unset($record['level_name']);
}
return $record;
}
示例7: write
public function write(array $record)
{
parent::write($record);
$this->closeSocket();
}
示例8: write
/**
* {@inheritdoc}
*
* @param array $record
*/
protected function write(array $record)
{
parent::write($record);
$res = $this->getResource();
if (is_resource($res)) {
@fread($res, 2048);
}
$this->closeSocket();
}
示例9: write
/**
* {@inheritdoc}
*
* @param array $record
*/
protected function write(array $record)
{
try {
parent::write($record);
$this->closeSocket();
} catch (\Exception $e) {
// socket creation failed. Cannot connect to hipchat API.
}
}
示例10: getFormatter
public function getFormatter()
{
$formatter = parent::getFormatter();
$this->slackRecord->setFormatter($formatter);
return $formatter;
}