Файловый менеджер - Редактировать - /var/www/html/Monolog.zip
Ðазад
PK ! f>t�7 7 Formatter/StatsDFormatter.phpnu �Iw�� <?php namespace Liuggio\StatsdClient\Monolog\Formatter; use Monolog\Formatter\LineFormatter; /** * Formats incoming records in order to be a perfect StatsD key. * * This is especially useful for logging to files * * @author Jordi Boggiano <j.boggiano@seld.be> * @author Christophe Coevoet <stof@notk.org> * @author Giulio De Donato <liuggio@gmail.com> */ class StatsDFormatter extends LineFormatter { const SIMPLE_FORMAT = "%channel%.%level_name%.%short_message%"; protected $numberOfWords; protected $logContext; protected $logExtra; /** * @param string $format The format of the message * @param Boolean $logContext If true add multiple rows containing Context information * @param Boolean $logExtra If true add multiple rows containing Extra information * @param integer $numberOfWords The number of words to show. */ public function __construct($format = null, $logContext = true, $logExtra = true, $numberOfWords = 2) { $this->format = $format ? : static::SIMPLE_FORMAT; $this->numberOfWords = $numberOfWords; $this->logContext = $logContext; $this->logExtra = $logExtra; parent::__construct(); } /** * This function converts a long message into a string with the first N-words. * eg. from: "Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener" * to: "Notified event" * * @param string $message The message to shortify. * * @return string */ public function getFirstWords($message) { $glue = '-'; $pieces = explode(' ', $message); array_splice($pieces, $this->numberOfWords); $shortMessage = preg_replace("/[^A-Za-z0-9?![:space:]]/", "-", implode($glue, $pieces)); return $shortMessage; } /** * {@inheritdoc} */ public function format(array $record) { $vars = $this->normalize($record); $firstRow = $this->format; $output = array(); $vars['short_message'] = $this->getFirstWords($vars['message']); foreach ($vars as $var => $val) { $firstRow = str_replace('%' . $var . '%', $this->convertToString($val), $firstRow); } $output[] = $firstRow; // creating more rows for context content if ($this->logContext && isset($vars['context'])) { foreach ($vars['context'] as $key => $parameter) { if (!is_string($parameter)) { $parameter = json_encode($parameter); } $output[] = sprintf("%s.context.%s.%s", $firstRow, $key, $parameter); } } // creating more rows for extra content if ($this->logExtra && isset($vars['extra'])) { foreach ($vars['extra'] as $key => $parameter) { if (!is_string($parameter)) { $parameter = json_encode($parameter); } $output[] = sprintf("%s.extra.%s.%s", $firstRow, $key, $parameter); } } return $output; } /** * {@inheritdoc} */ public function formatBatch(array $records) { $output = array(); foreach ($records as $record) { $output = array_merge($output, $this->format($record)); } return $output; } }PK ! �M��� � Handler/StatsDHandler.phpnu �Iw�� <?php namespace Liuggio\StatsdClient\Monolog\Handler; use Monolog\Logger; use Monolog\Handler\AbstractProcessingHandler; use Monolog\Formatter\FormatterInterface; use Liuggio\StatsdClient\Monolog\Formatter\StatsDFormatter; use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use Liuggio\StatsdClient\Factory\StatsdDataFactory; use Liuggio\StatsdClient\StatsdClientInterface; /** * A processing handler for StatsD. * * @author Giulio De Donato <liuggio@gmail.com> */ class StatsDHandler extends AbstractProcessingHandler { /** * @var array */ protected $buffer = array(); /** * @var string */ protected $prefix; /** * @var statsDService */ protected $statsDService; /** * @var statsDFactory */ protected $statsDFactory; /** * @param StatsdClientInterface $statsDService The Service sends the packet * @param StatsdDataFactoryInterface $statsDFactory The Factory creates the StatsDPacket * @param string $prefix Statsd key prefix * @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(StatsdClientInterface $statsDService, StatsdDataFactoryInterface $statsDFactory = null, $prefix, $level = Logger::DEBUG, $bubble = true) { parent::__construct($level, $bubble); $this->statsDService = $statsDService; $this->statsDFactory = $statsDFactory ? $statsDFactory : new StatsdDataFactory(); $this->prefix = $prefix; } /** * {@inheritdoc} */ public function close() { $this->statsDService->send($this->buffer); } /** * {@inheritdoc} */ protected function write(array $record) { $records = is_array($record['formatted']) ? $record['formatted'] : array($record['formatted']); foreach ($records as $record) { if (!empty($record)) { $this->buffer[] = $this->statsDFactory->increment(sprintf('%s.%s', $this->getPrefix(), $record)); } } } /** * Gets the default formatter. * * @return FormatterInterface */ protected function getDefaultFormatter() { return new StatsDFormatter(); } /** * @param string $prefix */ public function setPrefix($prefix) { $this->prefix = $prefix; } /** * @return string */ public function getPrefix() { return $this->prefix; } /** * @param StatsdClientInterface $statsDService */ public function setStatsDService(StatsdClientInterface $statsDService) { $this->statsDService = $statsDService; } /** * @param StatsdDataFactoryInterface $statsDFactory */ public function setStatsDFactory(StatsdDataFactoryInterface $statsDFactory) { $this->statsDFactory = $statsDFactory; } } PK ! f>t�7 7 Formatter/StatsDFormatter.phpnu �Iw�� PK ! �M��� � � Handler/StatsDHandler.phpnu �Iw�� PK � �
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка