作者:limoncello-ph
项目:ap
/**
* @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;
};
}
作者:wushia
项目:MD
/**
* @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();
}
作者:saj69
项目:pip
/**
* @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;
}
作者:reTHINK-projec
项目:dev-IdPServer-phpOID
public function write(array $record)
{
foreach ($this->users as $user) {
$this->user = $user;
parent::write($record);
$this->closeSocket();
}
$this->user = null;
}
作者:earnce
项目:monolo
/**
* @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;
}
作者:pilebone
项目:logstashMonologHandlerBundl
/**
* @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;
}
作者:kalaspuffa
项目:php-orm-benchmar
public function write(array $record)
{
parent::write($record);
$this->closeSocket();
}
作者:Roc4rdh
项目:ap
/**
* {@inheritdoc}
*
* @param array $record
*/
protected function write(array $record)
{
parent::write($record);
$res = $this->getResource();
if (is_resource($res)) {
@fread($res, 2048);
}
$this->closeSocket();
}
作者:alextarta
项目:monolo
/**
* {@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.
}
}
作者:nald
项目:cyberde
public function getFormatter()
{
$formatter = parent::getFormatter();
$this->slackRecord->setFormatter($formatter);
return $formatter;
}