Файловый менеджер - Редактировать - /home/lakoyani/lakoyani.com.fj/Processor.tar
Назад
ProcessorInterface.php 0000777 00000001011 14711055514 0011060 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * An optional interface to allow labelling Monolog processors. * * @author Nicolas Grekas <p@tchwork.com> */ interface ProcessorInterface { /** * @return array The processed records */ public function __invoke(array $records); } MemoryPeakUsageProcessor.php 0000777 00000001426 14711055514 0012230 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Injects memory_get_peak_usage in all records * * @see Monolog\Processor\MemoryProcessor::__construct() for options * @author Rob Jensen */ class MemoryPeakUsageProcessor extends MemoryProcessor { /** * @param array $record * @return array */ public function __invoke(array $record) { $bytes = memory_get_peak_usage($this->realUsage); $formatted = $this->formatBytes($bytes); $record['extra']['memory_peak_usage'] = $formatted; return $record; } } MercurialProcessor.php 0000777 00000002603 14711055514 0011113 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jonathan A. Schweder <jonathanschweder@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; use Monolog\Logger; /** * Injects Hg branch and Hg revision number in all records * * @author Jonathan A. Schweder <jonathanschweder@gmail.com> */ class MercurialProcessor implements ProcessorInterface { private $level; private static $cache; public function __construct($level = Logger::DEBUG) { $this->level = Logger::toMonologLevel($level); } /** * @param array $record * @return array */ public function __invoke(array $record) { // return if the level is not high enough if ($record['level'] < $this->level) { return $record; } $record['extra']['hg'] = self::getMercurialInfo(); return $record; } private static function getMercurialInfo() { if (self::$cache) { return self::$cache; } $result = explode(' ', trim(`hg id -nb`)); if (count($result) >= 3) { return self::$cache = array( 'branch' => $result[1], 'revision' => $result[2], ); } return self::$cache = array(); } } GitProcessor.php 0000777 00000002651 14711055514 0007716 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; use Monolog\Logger; /** * Injects Git branch and Git commit SHA in all records * * @author Nick Otter * @author Jordi Boggiano <j.boggiano@seld.be> */ class GitProcessor implements ProcessorInterface { private $level; private static $cache; public function __construct($level = Logger::DEBUG) { $this->level = Logger::toMonologLevel($level); } /** * @param array $record * @return array */ public function __invoke(array $record) { // return if the level is not high enough if ($record['level'] < $this->level) { return $record; } $record['extra']['git'] = self::getGitInfo(); return $record; } private static function getGitInfo() { if (self::$cache) { return self::$cache; } $branches = `git branch -v --no-abbrev`; if ($branches && preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) { return self::$cache = array( 'branch' => $matches[1], 'commit' => $matches[2], ); } return self::$cache = array(); } } PsrLogMessageProcessor.php 0000777 00000004673 14711055514 0011714 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; use Monolog\Utils; /** * Processes a record's message according to PSR-3 rules * * It replaces {foo} with the value from $context['foo'] * * @author Jordi Boggiano <j.boggiano@seld.be> */ class PsrLogMessageProcessor implements ProcessorInterface { const SIMPLE_DATE = "Y-m-d\TH:i:s.uP"; /** @var string|null */ private $dateFormat; /** @var bool */ private $removeUsedContextFields; /** * @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format * @param bool $removeUsedContextFields If set to true the fields interpolated into message gets unset */ public function __construct($dateFormat = null, $removeUsedContextFields = false) { $this->dateFormat = $dateFormat; $this->removeUsedContextFields = $removeUsedContextFields; } /** * @param array $record * @return array */ public function __invoke(array $record) { if (false === strpos($record['message'], '{')) { return $record; } $replacements = array(); foreach ($record['context'] as $key => $val) { $placeholder = '{' . $key . '}'; if (strpos($record['message'], $placeholder) === false) { continue; } if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { $replacements[$placeholder] = $val; } elseif ($val instanceof \DateTime) { $replacements[$placeholder] = $val->format($this->dateFormat ?: static::SIMPLE_DATE); } elseif (is_object($val)) { $replacements[$placeholder] = '[object '.Utils::getClass($val).']'; } elseif (is_array($val)) { $replacements[$placeholder] = 'array'.Utils::jsonEncode($val, null, true); } else { $replacements[$placeholder] = '['.gettype($val).']'; } if ($this->removeUsedContextFields) { unset($record['context'][$key]); } } $record['message'] = strtr($record['message'], $replacements); return $record; } } WebProcessor.php 0000777 00000006243 14711055514 0007711 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Injects url/method and remote IP of the current web request in all records * * @author Jordi Boggiano <j.boggiano@seld.be> */ class WebProcessor implements ProcessorInterface { /** * @var array|\ArrayAccess */ protected $serverData; /** * Default fields * * Array is structured as [key in record.extra => key in $serverData] * * @var array */ protected $extraFields = array( 'url' => 'REQUEST_URI', 'ip' => 'REMOTE_ADDR', 'http_method' => 'REQUEST_METHOD', 'server' => 'SERVER_NAME', 'referrer' => 'HTTP_REFERER', ); /** * @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data * @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer */ public function __construct($serverData = null, array $extraFields = null) { if (null === $serverData) { $this->serverData = &$_SERVER; } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) { $this->serverData = $serverData; } else { throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.'); } if (isset($this->serverData['UNIQUE_ID'])) { $this->extraFields['unique_id'] = 'UNIQUE_ID'; } if (null !== $extraFields) { if (isset($extraFields[0])) { foreach (array_keys($this->extraFields) as $fieldName) { if (!in_array($fieldName, $extraFields)) { unset($this->extraFields[$fieldName]); } } } else { $this->extraFields = $extraFields; } } } /** * @param array $record * @return array */ public function __invoke(array $record) { // skip processing if for some reason request data // is not present (CLI or wonky SAPIs) if (!isset($this->serverData['REQUEST_URI'])) { return $record; } $record['extra'] = $this->appendExtraFields($record['extra']); return $record; } /** * @param string $extraName * @param string $serverName * @return $this */ public function addExtraField($extraName, $serverName) { $this->extraFields[$extraName] = $serverName; return $this; } /** * @param array $extra * @return array */ private function appendExtraFields(array $extra) { foreach ($this->extraFields as $extraName => $serverName) { $extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null; } return $extra; } } MemoryProcessor.php 0000777 00000003451 14711055514 0010442 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Some methods that are common for all memory processors * * @author Rob Jensen */ abstract class MemoryProcessor implements ProcessorInterface { /** * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. */ protected $realUsage; /** * @var bool If true, then format memory size to human readable string (MB, KB, B depending on size) */ protected $useFormatting; /** * @param bool $realUsage Set this to true to get the real size of memory allocated from system. * @param bool $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size) */ public function __construct($realUsage = true, $useFormatting = true) { $this->realUsage = (bool) $realUsage; $this->useFormatting = (bool) $useFormatting; } /** * Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is * * @param int $bytes * @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is */ protected function formatBytes($bytes) { $bytes = (int) $bytes; if (!$this->useFormatting) { return $bytes; } if ($bytes > 1024 * 1024) { return round($bytes / 1024 / 1024, 2).' MB'; } elseif ($bytes > 1024) { return round($bytes / 1024, 2).' KB'; } return $bytes . ' B'; } } IntrospectionProcessor.php 0000777 00000006755 14711055514 0012044 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; use Monolog\Logger; /** * Injects line/file:class/function where the log message came from * * Warning: This only works if the handler processes the logs directly. * If you put the processor on a handler that is behind a FingersCrossedHandler * for example, the processor will only be called once the trigger level is reached, * and all the log records will have the same file/line/.. data from the call that * triggered the FingersCrossedHandler. * * @author Jordi Boggiano <j.boggiano@seld.be> */ class IntrospectionProcessor implements ProcessorInterface { private $level; private $skipClassesPartials; private $skipStackFramesCount; private $skipFunctions = array( 'call_user_func', 'call_user_func_array', ); public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0) { $this->level = Logger::toMonologLevel($level); $this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials); $this->skipStackFramesCount = $skipStackFramesCount; } /** * @param array $record * @return array */ public function __invoke(array $record) { // return if the level is not high enough if ($record['level'] < $this->level) { return $record; } /* * http://php.net/manual/en/function.debug-backtrace.php * As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added. * Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'. */ $trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS); // skip first since it's always the current method array_shift($trace); // the call_user_func call is also skipped array_shift($trace); $i = 0; while ($this->isTraceClassOrSkippedFunction($trace, $i)) { if (isset($trace[$i]['class'])) { foreach ($this->skipClassesPartials as $part) { if (strpos($trace[$i]['class'], $part) !== false) { $i++; continue 2; } } } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) { $i++; continue; } break; } $i += $this->skipStackFramesCount; // we should have the call source now $record['extra'] = array_merge( $record['extra'], array( 'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null, 'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null, 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, ) ); return $record; } private function isTraceClassOrSkippedFunction(array $trace, $index) { if (!isset($trace[$index])) { return false; } return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions); } } UidProcessor.php 0000777 00000002317 14711055514 0007713 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; use Monolog\ResettableInterface; /** * Adds a unique identifier into records * * @author Simon Mönch <sm@webfactory.de> */ class UidProcessor implements ProcessorInterface, ResettableInterface { private $uid; public function __construct($length = 7) { if (!is_int($length) || $length > 32 || $length < 1) { throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32'); } $this->uid = $this->generateUid($length); } public function __invoke(array $record) { $record['extra']['uid'] = $this->uid; return $record; } /** * @return string */ public function getUid() { return $this->uid; } public function reset() { $this->uid = $this->generateUid(strlen($this->uid)); } private function generateUid($length) { return substr(hash('md5', uniqid('', true)), 0, $length); } } ProcessIdProcessor.php 0000777 00000001134 14711055514 0011061 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Adds value of getmypid into records * * @author Andreas Hörnicke */ class ProcessIdProcessor implements ProcessorInterface { /** * @param array $record * @return array */ public function __invoke(array $record) { $record['extra']['process_id'] = getmypid(); return $record; } } MemoryUsageProcessor.php 0000777 00000001403 14711055514 0011422 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Injects memory_get_usage in all records * * @see Monolog\Processor\MemoryProcessor::__construct() for options * @author Rob Jensen */ class MemoryUsageProcessor extends MemoryProcessor { /** * @param array $record * @return array */ public function __invoke(array $record) { $bytes = memory_get_usage($this->realUsage); $formatted = $this->formatBytes($bytes); $record['extra']['memory_usage'] = $formatted; return $record; } } TagProcessor.php 0000777 00000001522 14711055514 0007702 0 ustar 00 <?php /* * This file is part of the Monolog package. * * (c) Jordi Boggiano <j.boggiano@seld.be> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Monolog\Processor; /** * Adds a tags array into record * * @author Martijn Riemers */ class TagProcessor implements ProcessorInterface { private $tags; public function __construct(array $tags = array()) { $this->setTags($tags); } public function addTags(array $tags = array()) { $this->tags = array_merge($this->tags, $tags); } public function setTags(array $tags = array()) { $this->tags = $tags; } public function __invoke(array $record) { $record['extra']['tags'] = $this->tags; return $record; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка