mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-26 18:16:24 +01:00
CS fixes
This commit is contained in:
@@ -36,7 +36,7 @@ class ErrorHandler
|
||||
private $hasFatalErrorHandler;
|
||||
private $fatalLevel;
|
||||
private $reservedMemory;
|
||||
private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR);
|
||||
private static $fatalErrors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
|
||||
|
||||
public function __construct(LoggerInterface $logger)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ class ErrorHandler
|
||||
* @param int|false $fatalLevel a LogLevel::* constant, or false to disable fatal error handling
|
||||
* @return ErrorHandler
|
||||
*/
|
||||
public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevelMap = array(), $fatalLevel = null)
|
||||
public static function register(LoggerInterface $logger, $errorLevelMap = [], $exceptionLevelMap = [], $fatalLevel = null)
|
||||
{
|
||||
$handler = new static($logger);
|
||||
if ($errorLevelMap !== false) {
|
||||
@@ -70,18 +70,18 @@ class ErrorHandler
|
||||
return $handler;
|
||||
}
|
||||
|
||||
public function registerExceptionHandler($levelMap = array(), $callPrevious = true)
|
||||
public function registerExceptionHandler($levelMap = [], $callPrevious = true)
|
||||
{
|
||||
$prev = set_exception_handler(array($this, 'handleException'));
|
||||
$prev = set_exception_handler([$this, 'handleException']);
|
||||
$this->uncaughtExceptionLevelMap = array_replace($this->defaultExceptionLevelMap(), $levelMap);
|
||||
if ($callPrevious && $prev) {
|
||||
$this->previousExceptionHandler = $prev;
|
||||
}
|
||||
}
|
||||
|
||||
public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1)
|
||||
public function registerErrorHandler(array $levelMap = [], $callPrevious = true, $errorTypes = -1)
|
||||
{
|
||||
$prev = set_error_handler(array($this, 'handleError'), $errorTypes);
|
||||
$prev = set_error_handler([$this, 'handleError'], $errorTypes);
|
||||
$this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);
|
||||
if ($callPrevious) {
|
||||
$this->previousErrorHandler = $prev ?: true;
|
||||
@@ -90,7 +90,7 @@ class ErrorHandler
|
||||
|
||||
public function registerFatalHandler($level = null, $reservedMemorySize = 20)
|
||||
{
|
||||
register_shutdown_function(array($this, 'handleFatalError'));
|
||||
register_shutdown_function([$this, 'handleFatalError']);
|
||||
|
||||
$this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);
|
||||
$this->fatalLevel = $level;
|
||||
@@ -99,15 +99,15 @@ class ErrorHandler
|
||||
|
||||
protected function defaultExceptionLevelMap()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'ParseError' => LogLevel::CRITICAL,
|
||||
'Throwable' => LogLevel::ERROR,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function defaultErrorLevelMap()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
E_ERROR => LogLevel::CRITICAL,
|
||||
E_WARNING => LogLevel::WARNING,
|
||||
E_PARSE => LogLevel::ALERT,
|
||||
@@ -123,7 +123,7 @@ class ErrorHandler
|
||||
E_RECOVERABLE_ERROR => LogLevel::ERROR,
|
||||
E_DEPRECATED => LogLevel::NOTICE,
|
||||
E_USER_DEPRECATED => LogLevel::NOTICE,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ class ErrorHandler
|
||||
$this->logger->log(
|
||||
$level,
|
||||
sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
|
||||
array('exception' => $e)
|
||||
['exception' => $e]
|
||||
);
|
||||
|
||||
if ($this->previousExceptionHandler) {
|
||||
@@ -155,7 +155,7 @@ class ErrorHandler
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function handleError($code, $message, $file = '', $line = 0, $context = array())
|
||||
public function handleError($code, $message, $file = '', $line = 0, $context = [])
|
||||
{
|
||||
if (!(error_reporting() & $code)) {
|
||||
return;
|
||||
@@ -164,7 +164,7 @@ class ErrorHandler
|
||||
// fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries
|
||||
if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) {
|
||||
$level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL;
|
||||
$this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line));
|
||||
$this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
|
||||
}
|
||||
|
||||
if ($this->previousErrorHandler === true) {
|
||||
@@ -186,7 +186,7 @@ class ErrorHandler
|
||||
$this->logger->log(
|
||||
$this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel,
|
||||
'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'],
|
||||
array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'])
|
||||
['code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line']]
|
||||
);
|
||||
|
||||
if ($this->logger instanceof Logger) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class ChromePHPFormatter implements FormatterInterface
|
||||
/**
|
||||
* Translates Monolog log levels to Wildfire levels.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
private $logLevels = [
|
||||
Logger::DEBUG => 'log',
|
||||
Logger::INFO => 'info',
|
||||
Logger::NOTICE => 'info',
|
||||
@@ -32,7 +32,7 @@ class ChromePHPFormatter implements FormatterInterface
|
||||
Logger::CRITICAL => 'error',
|
||||
Logger::ALERT => 'error',
|
||||
Logger::EMERGENCY => 'error',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -46,7 +46,7 @@ class ChromePHPFormatter implements FormatterInterface
|
||||
unset($record['extra']['file'], $record['extra']['line']);
|
||||
}
|
||||
|
||||
$message = array('message' => $record['message']);
|
||||
$message = ['message' => $record['message']];
|
||||
if ($record['context']) {
|
||||
$message['context'] = $record['context'];
|
||||
}
|
||||
@@ -57,17 +57,17 @@ class ChromePHPFormatter implements FormatterInterface
|
||||
$message = reset($message);
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
$record['channel'],
|
||||
$message,
|
||||
$backtrace,
|
||||
$this->logLevels[$record['level']],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function formatBatch(array $records)
|
||||
{
|
||||
$formatted = array();
|
||||
$formatted = [];
|
||||
|
||||
foreach ($records as $record) {
|
||||
$formatted[] = $this->format($record);
|
||||
|
||||
@@ -43,11 +43,11 @@ class FlowdockFormatter implements FormatterInterface
|
||||
*/
|
||||
public function format(array $record)
|
||||
{
|
||||
$tags = array(
|
||||
$tags = [
|
||||
'#logs',
|
||||
'#' . strtolower($record['level_name']),
|
||||
'#' . $record['channel'],
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($record['extra'] as $value) {
|
||||
$tags[] = '#' . $value;
|
||||
@@ -60,14 +60,14 @@ class FlowdockFormatter implements FormatterInterface
|
||||
$this->getShortMessage($record['message'])
|
||||
);
|
||||
|
||||
$record['flowdock'] = array(
|
||||
$record['flowdock'] = [
|
||||
'source' => $this->source,
|
||||
'from_address' => $this->sourceEmail,
|
||||
'subject' => $subject,
|
||||
'content' => $record['message'],
|
||||
'tags' => $tags,
|
||||
'project' => $this->source,
|
||||
);
|
||||
];
|
||||
|
||||
return $record;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class FlowdockFormatter implements FormatterInterface
|
||||
*/
|
||||
public function formatBatch(array $records)
|
||||
{
|
||||
$formatted = array();
|
||||
$formatted = [];
|
||||
|
||||
foreach ($records as $record) {
|
||||
$formatted[] = $this->format($record);
|
||||
|
||||
@@ -60,17 +60,17 @@ class FluentdFormatter implements FormatterInterface
|
||||
$tag .= '.' . strtolower($record['level_name']);
|
||||
}
|
||||
|
||||
$message = array(
|
||||
$message = [
|
||||
'message' => $record['message'],
|
||||
'extra' => $record['extra'],
|
||||
);
|
||||
];
|
||||
|
||||
if (!$this->levelTag) {
|
||||
$message['level'] = $record['level'];
|
||||
$message['level_name'] = $record['level_name'];
|
||||
}
|
||||
|
||||
return json_encode(array($tag, $record['datetime']->getTimestamp(), $message));
|
||||
return json_encode([$tag, $record['datetime']->getTimestamp(), $message]);
|
||||
}
|
||||
|
||||
public function formatBatch(array $records)
|
||||
|
||||
@@ -42,7 +42,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
/**
|
||||
* Translates Monolog log levels to Graylog2 log priorities.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
private $logLevels = [
|
||||
Logger::DEBUG => 7,
|
||||
Logger::INFO => 6,
|
||||
Logger::NOTICE => 5,
|
||||
@@ -51,7 +51,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
Logger::CRITICAL => 2,
|
||||
Logger::ALERT => 1,
|
||||
Logger::EMERGENCY => 0,
|
||||
);
|
||||
];
|
||||
|
||||
public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_')
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class HtmlFormatter extends NormalizerFormatter
|
||||
/**
|
||||
* Translates Monolog log levels to html color priorities.
|
||||
*/
|
||||
protected $logLevels = array(
|
||||
protected $logLevels = [
|
||||
Logger::DEBUG => '#cccccc',
|
||||
Logger::INFO => '#468847',
|
||||
Logger::NOTICE => '#3a87ad',
|
||||
@@ -33,7 +33,7 @@ class HtmlFormatter extends NormalizerFormatter
|
||||
Logger::CRITICAL => '#FF7708',
|
||||
Logger::ALERT => '#C12A19',
|
||||
Logger::EMERGENCY => '#000000',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
|
||||
|
||||
@@ -138,7 +138,7 @@ class JsonFormatter extends NormalizerFormatter
|
||||
protected function normalize($data)
|
||||
{
|
||||
if (is_array($data) || $data instanceof \Traversable) {
|
||||
$normalized = array();
|
||||
$normalized = [];
|
||||
|
||||
$count = 1;
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -169,12 +169,12 @@ class JsonFormatter extends NormalizerFormatter
|
||||
*/
|
||||
protected function normalizeException(\Throwable $e)
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'class' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile().':'.$e->getLine(),
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->includeStacktraces) {
|
||||
$trace = $e->getTrace();
|
||||
|
||||
@@ -155,6 +155,6 @@ class LineFormatter extends NormalizerFormatter
|
||||
return $str;
|
||||
}
|
||||
|
||||
return str_replace(array("\r\n", "\r", "\n"), ' ', $str);
|
||||
return str_replace(["\r\n", "\r", "\n"], ' ', $str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ class LogstashFormatter extends NormalizerFormatter
|
||||
if (empty($record['datetime'])) {
|
||||
$record['datetime'] = gmdate('c');
|
||||
}
|
||||
$message = array(
|
||||
$message = [
|
||||
'@timestamp' => $record['datetime'],
|
||||
'@version' => 1,
|
||||
'host' => $this->systemName,
|
||||
);
|
||||
];
|
||||
if (isset($record['message'])) {
|
||||
$message['message'] = $record['message'];
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ class MongoDBFormatter implements FormatterInterface
|
||||
|
||||
protected function formatException(\Throwable $exception, $nestingLevel)
|
||||
{
|
||||
$formattedException = array(
|
||||
$formattedException = [
|
||||
'class' => get_class($exception),
|
||||
'message' => $exception->getMessage(),
|
||||
'code' => $exception->getCode(),
|
||||
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->exceptionTraceAsString === true) {
|
||||
$formattedException['trace'] = $exception->getTraceAsString();
|
||||
|
||||
@@ -72,7 +72,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
}
|
||||
|
||||
if (is_array($data) || $data instanceof \Traversable) {
|
||||
$normalized = array();
|
||||
$normalized = [];
|
||||
|
||||
$count = 1;
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -90,6 +90,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
if ($data instanceof DateTimeImmutable) {
|
||||
return (string) $data;
|
||||
}
|
||||
|
||||
return $data->format($this->dateFormat ?: static::SIMPLE_DATE);
|
||||
}
|
||||
|
||||
@@ -124,12 +125,12 @@ class NormalizerFormatter implements FormatterInterface
|
||||
|
||||
protected function normalizeException(Throwable $e)
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'class' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile().':'.$e->getLine(),
|
||||
);
|
||||
];
|
||||
|
||||
$trace = $e->getTrace();
|
||||
foreach ($trace as $frame) {
|
||||
@@ -176,7 +177,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @param mixed $data
|
||||
* @return string|bool JSON encoded data or false on failure
|
||||
*/
|
||||
private function jsonEncode($data)
|
||||
@@ -206,7 +207,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
if (is_string($data)) {
|
||||
$this->detectAndCleanUtf8($data);
|
||||
} elseif (is_array($data)) {
|
||||
array_walk_recursive($data, array($this, 'detectAndCleanUtf8'));
|
||||
array_walk_recursive($data, [$this, 'detectAndCleanUtf8']);
|
||||
} else {
|
||||
$this->throwEncodeError($code, $data);
|
||||
}
|
||||
@@ -274,8 +275,8 @@ class NormalizerFormatter implements FormatterInterface
|
||||
$data
|
||||
);
|
||||
$data = str_replace(
|
||||
array('¤', '¦', '¨', '´', '¸', '¼', '½', '¾'),
|
||||
array('€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'),
|
||||
['¤', '¦', '¨', '´', '¸', '¼', '½', '¾'],
|
||||
['€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'],
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
/**
|
||||
* Translates Monolog log levels to Wildfire levels.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
private $logLevels = [
|
||||
Logger::DEBUG => 'LOG',
|
||||
Logger::INFO => 'INFO',
|
||||
Logger::NOTICE => 'INFO',
|
||||
@@ -36,7 +36,7 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
Logger::CRITICAL => 'ERROR',
|
||||
Logger::ALERT => 'ERROR',
|
||||
Logger::EMERGENCY => 'ERROR',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -55,7 +55,7 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
}
|
||||
|
||||
$record = $this->normalize($record);
|
||||
$message = array('message' => $record['message']);
|
||||
$message = ['message' => $record['message']];
|
||||
$handleError = false;
|
||||
if ($record['context']) {
|
||||
$message['context'] = $record['context'];
|
||||
@@ -79,15 +79,15 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
}
|
||||
|
||||
// Create JSON object describing the appearance of the message in the console
|
||||
$json = $this->toJson(array(
|
||||
array(
|
||||
$json = $this->toJson([
|
||||
[
|
||||
'Type' => $type,
|
||||
'File' => $file,
|
||||
'Line' => $line,
|
||||
'Label' => $label,
|
||||
),
|
||||
],
|
||||
$message,
|
||||
), $handleError);
|
||||
], $handleError);
|
||||
|
||||
// The message itself is a serialization of the above JSON object + it's length
|
||||
return sprintf(
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Translates Monolog log levels to syslog log priorities.
|
||||
*/
|
||||
protected $logLevels = array(
|
||||
protected $logLevels = [
|
||||
Logger::DEBUG => LOG_DEBUG,
|
||||
Logger::INFO => LOG_INFO,
|
||||
Logger::NOTICE => LOG_NOTICE,
|
||||
@@ -34,12 +34,12 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
|
||||
Logger::CRITICAL => LOG_CRIT,
|
||||
Logger::ALERT => LOG_ALERT,
|
||||
Logger::EMERGENCY => LOG_EMERG,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* List of valid log facility names.
|
||||
*/
|
||||
protected $facilities = array(
|
||||
protected $facilities = [
|
||||
'auth' => LOG_AUTH,
|
||||
'authpriv' => LOG_AUTHPRIV,
|
||||
'cron' => LOG_CRON,
|
||||
@@ -51,7 +51,7 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler
|
||||
'syslog' => LOG_SYSLOG,
|
||||
'user' => LOG_USER,
|
||||
'uucp' => LOG_UUCP,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param mixed $facility
|
||||
|
||||
@@ -61,10 +61,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
||||
$data,
|
||||
$routingKey,
|
||||
0,
|
||||
array(
|
||||
[
|
||||
'delivery_mode' => 2,
|
||||
'content_type' => 'application/json',
|
||||
)
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->exchange->basic_publish(
|
||||
@@ -125,10 +125,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
||||
{
|
||||
return new AMQPMessage(
|
||||
(string) $data,
|
||||
array(
|
||||
[
|
||||
'delivery_mode' => 2,
|
||||
'content_type' => 'application/json',
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use Monolog\Formatter\FormatterInterface;
|
||||
class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
{
|
||||
protected static $initialized = false;
|
||||
protected static $records = array();
|
||||
protected static $records = [];
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -79,7 +79,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public static function reset()
|
||||
{
|
||||
self::$records = array();
|
||||
self::$records = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
protected function registerShutdownFunction()
|
||||
{
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send'));
|
||||
register_shutdown_function(['Monolog\Handler\BrowserConsoleHandler', 'send']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
|
||||
private static function generateScript()
|
||||
{
|
||||
$script = array();
|
||||
$script = [];
|
||||
foreach (self::$records as $record) {
|
||||
$context = self::dump('Context', $record['context']);
|
||||
$extra = self::dump('Extra', $record['extra']);
|
||||
@@ -142,10 +142,10 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
$script[] = self::call_array('log', self::handleStyles($record['formatted']));
|
||||
} else {
|
||||
$script = array_merge($script,
|
||||
array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))),
|
||||
[self::call_array('groupCollapsed', self::handleStyles($record['formatted']))],
|
||||
$context,
|
||||
$extra,
|
||||
array(self::call('groupEnd'))
|
||||
[self::call('groupEnd')]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
|
||||
private static function handleStyles($formatted)
|
||||
{
|
||||
$args = array(self::quote('font-weight: normal'));
|
||||
$args = [self::quote('font-weight: normal')];
|
||||
$format = '%c' . $formatted;
|
||||
preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
|
||||
|
||||
@@ -174,8 +174,8 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
|
||||
private static function handleCustomStyles($style, $string)
|
||||
{
|
||||
static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey');
|
||||
static $labels = array();
|
||||
static $colors = ['blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey'];
|
||||
static $labels = [];
|
||||
|
||||
return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) {
|
||||
if (trim($m[1]) === 'autolabel') {
|
||||
@@ -194,7 +194,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
|
||||
private static function dump($title, array $dict)
|
||||
{
|
||||
$script = array();
|
||||
$script = [];
|
||||
$dict = array_filter($dict);
|
||||
if (empty($dict)) {
|
||||
return $script;
|
||||
|
||||
@@ -29,7 +29,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
|
||||
protected $bufferSize = 0;
|
||||
protected $bufferLimit;
|
||||
protected $flushOnOverflow;
|
||||
protected $buffer = array();
|
||||
protected $buffer = [];
|
||||
protected $initialized = false;
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
|
||||
|
||||
if (!$this->initialized) {
|
||||
// __destructor() doesn't get called on Fatal errors
|
||||
register_shutdown_function(array($this, 'close'));
|
||||
register_shutdown_function([$this, 'close']);
|
||||
$this->initialized = true;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,6 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
|
||||
public function clear()
|
||||
{
|
||||
$this->bufferSize = 0;
|
||||
$this->buffer = array();
|
||||
$this->buffer = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
protected static $overflowed = false;
|
||||
|
||||
protected static $json = array(
|
||||
protected static $json = [
|
||||
'version' => self::VERSION,
|
||||
'columns' => array('label', 'log', 'backtrace', 'type'),
|
||||
'rows' => array(),
|
||||
);
|
||||
'columns' => ['label', 'log', 'backtrace', 'type'],
|
||||
'rows' => [],
|
||||
];
|
||||
|
||||
protected static $sendHeaders = true;
|
||||
|
||||
@@ -75,7 +75,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public function handleBatch(array $records)
|
||||
{
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
foreach ($records as $record) {
|
||||
if ($record['level'] < $this->level) {
|
||||
@@ -140,15 +140,15 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
if (strlen($data) > 240 * 1024) {
|
||||
self::$overflowed = true;
|
||||
|
||||
$record = array(
|
||||
$record = [
|
||||
'message' => 'Incomplete logs, chrome header size limit reached',
|
||||
'context' => array(),
|
||||
'context' => [],
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => Logger::getLevelName(Logger::WARNING),
|
||||
'channel' => 'monolog',
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
|
||||
$json = @json_encode(self::$json);
|
||||
$data = base64_encode(utf8_encode($json));
|
||||
|
||||
@@ -24,15 +24,15 @@ class CouchDBHandler extends AbstractProcessingHandler
|
||||
{
|
||||
private $options;
|
||||
|
||||
public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true)
|
||||
public function __construct(array $options = [], $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
$this->options = array_merge(array(
|
||||
$this->options = array_merge([
|
||||
'host' => 'localhost',
|
||||
'port' => 5984,
|
||||
'dbname' => 'logger',
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
@@ -48,15 +48,15 @@ class CouchDBHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
$url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname'];
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
$context = stream_context_create([
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'content' => $record['formatted'],
|
||||
'ignore_errors' => true,
|
||||
'max_redirects' => 0,
|
||||
'header' => 'Content-type: application/json',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
if (false === @file_get_contents($url, null, $context)) {
|
||||
throw new \RuntimeException(sprintf('Could not connect to %s', $url));
|
||||
|
||||
@@ -26,7 +26,7 @@ class CubeHandler extends AbstractProcessingHandler
|
||||
private $scheme;
|
||||
private $host;
|
||||
private $port;
|
||||
private $acceptedSchemes = array('http', 'udp');
|
||||
private $acceptedSchemes = ['http', 'udp'];
|
||||
|
||||
/**
|
||||
* Create a Cube handler
|
||||
@@ -105,7 +105,7 @@ class CubeHandler extends AbstractProcessingHandler
|
||||
{
|
||||
$date = $record['datetime'];
|
||||
|
||||
$data = array('time' => $date->format('Y-m-d\TH:i:s.uO'));
|
||||
$data = ['time' => $date->format('Y-m-d\TH:i:s.uO')];
|
||||
unset($record['datetime']);
|
||||
|
||||
if (isset($record['context']['type'])) {
|
||||
@@ -141,10 +141,10 @@ class CubeHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
|
||||
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array(
|
||||
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen('['.$data.']'),
|
||||
));
|
||||
]);
|
||||
|
||||
Curl\Util::execute($this->httpConnection, 5, false);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Monolog\Handler\Curl;
|
||||
|
||||
class Util
|
||||
{
|
||||
private static $retriableErrorCodes = array(
|
||||
private static $retriableErrorCodes = [
|
||||
CURLE_COULDNT_RESOLVE_HOST,
|
||||
CURLE_COULDNT_CONNECT,
|
||||
CURLE_HTTP_NOT_FOUND,
|
||||
@@ -21,7 +21,7 @@ class Util
|
||||
CURLE_OPERATION_TIMEOUTED,
|
||||
CURLE_HTTP_POST_ERROR,
|
||||
CURLE_SSL_CONNECT_ERROR,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Executes a CURL request with optional retries and exception on failure
|
||||
|
||||
@@ -81,7 +81,6 @@ class DeduplicationHandler extends BufferHandler
|
||||
|
||||
foreach ($this->buffer as $record) {
|
||||
if ($record['level'] >= $this->deduplicationLevel) {
|
||||
|
||||
$passthru = $passthru || !$this->isDuplicate($record);
|
||||
if ($passthru) {
|
||||
$this->appendRecord($record);
|
||||
@@ -139,7 +138,7 @@ class DeduplicationHandler extends BufferHandler
|
||||
|
||||
$handle = fopen($this->deduplicationStore, 'rw+');
|
||||
flock($handle, LOCK_EX);
|
||||
$validLogs = array();
|
||||
$validLogs = [];
|
||||
|
||||
$timestampValidity = time() - $this->time;
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ class DynamoDbHandler extends AbstractProcessingHandler
|
||||
$filtered = $this->filterEmptyFields($record['formatted']);
|
||||
$formatted = $this->client->formatAttributes($filtered);
|
||||
|
||||
$this->client->putItem(array(
|
||||
$this->client->putItem([
|
||||
'TableName' => $this->table,
|
||||
'Item' => $formatted,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* @var array Handler config options
|
||||
*/
|
||||
protected $options = array();
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* @param Client $client Elastica Client object
|
||||
@@ -51,16 +51,16 @@ class ElasticSearchHandler extends AbstractProcessingHandler
|
||||
* @param int $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(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true)
|
||||
public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
$this->client = $client;
|
||||
$this->options = array_merge(
|
||||
array(
|
||||
[
|
||||
'index' => 'monolog', // Elastic index name
|
||||
'type' => 'record', // Elastic document type
|
||||
'ignore_error' => false, // Suppress Elastica exceptions
|
||||
),
|
||||
],
|
||||
$options
|
||||
);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class ElasticSearchHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
protected function write(array $record)
|
||||
{
|
||||
$this->bulkSend(array($record['formatted']));
|
||||
$this->bulkSend([$record['formatted']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,10 +52,10 @@ class ErrorLogHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public static function getAvailableTypes()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
self::OPERATING_SYSTEM,
|
||||
self::SAPI,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,7 +128,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface
|
||||
*/
|
||||
public function handleBatch(array $records)
|
||||
{
|
||||
$filtered = array();
|
||||
$filtered = [];
|
||||
foreach ($records as $record) {
|
||||
if ($this->isHandling($record)) {
|
||||
$filtered[] = $record;
|
||||
|
||||
@@ -42,7 +42,7 @@ class ChannelLevelActivationStrategy implements ActivationStrategyInterface
|
||||
* @param int $defaultActionLevel The default action level to be used if the record's category doesn't match any
|
||||
* @param array $channelToActionLevel An array that maps channel names to action levels.
|
||||
*/
|
||||
public function __construct($defaultActionLevel, $channelToActionLevel = array())
|
||||
public function __construct($defaultActionLevel, $channelToActionLevel = [])
|
||||
{
|
||||
$this->defaultActionLevel = Logger::toMonologLevel($defaultActionLevel);
|
||||
$this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel);
|
||||
|
||||
@@ -35,7 +35,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
|
||||
protected $activationStrategy;
|
||||
protected $buffering = true;
|
||||
protected $bufferSize;
|
||||
protected $buffer = array();
|
||||
protected $buffer = [];
|
||||
protected $stopBuffering;
|
||||
protected $passthruLevel;
|
||||
|
||||
@@ -98,7 +98,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
|
||||
}
|
||||
}
|
||||
$this->handler->handleBatch($this->buffer);
|
||||
$this->buffer = array();
|
||||
$this->buffer = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
|
||||
});
|
||||
if (count($this->buffer) > 0) {
|
||||
$this->handler->handleBatch($this->buffer);
|
||||
$this->buffer = array();
|
||||
$this->buffer = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->buffer = array();
|
||||
$this->buffer = [];
|
||||
$this->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class FirePHPHandler extends AbstractProcessingHandler
|
||||
{
|
||||
$header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta));
|
||||
|
||||
return array($header => $message);
|
||||
return [$header => $message];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ class FirePHPHandler extends AbstractProcessingHandler
|
||||
// Wildfire is extensible to support multiple protocols & plugins in a single request,
|
||||
// but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake.
|
||||
return $this->createHeader(
|
||||
array(1, 1, 1, self::$messageIndex++),
|
||||
[1, 1, 1, self::$messageIndex++],
|
||||
$record['formatted']
|
||||
);
|
||||
}
|
||||
@@ -104,9 +104,9 @@ class FirePHPHandler extends AbstractProcessingHandler
|
||||
{
|
||||
// Initial payload consists of required headers for Wildfire
|
||||
return array_merge(
|
||||
$this->createHeader(array('Protocol', 1), self::PROTOCOL_URI),
|
||||
$this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI),
|
||||
$this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI)
|
||||
$this->createHeader(['Protocol', 1], self::PROTOCOL_URI),
|
||||
$this->createHeader([1, 'Structure', 1], self::STRUCTURE_URI),
|
||||
$this->createHeader([1, 'Plugin', 1], self::PLUGIN_URI)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,9 @@ class FleepHookHandler extends SocketHandler
|
||||
*/
|
||||
private function buildContent($record)
|
||||
{
|
||||
$dataArray = array(
|
||||
$dataArray = [
|
||||
'message' => $record['formatted'],
|
||||
);
|
||||
];
|
||||
|
||||
return http_build_query($dataArray);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Gelf\PublisherInterface;
|
||||
use InvalidArgumentException;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\GelfMessageFormatter;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
|
||||
@@ -70,15 +70,15 @@ class HipChatHandler extends SocketHandler
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* @param string $token HipChat API Token
|
||||
* @param string $room The room that should be alerted of the message (Id or Name)
|
||||
* @param string $name Name used in the "from" field.
|
||||
* @param bool $notify Trigger a notification in clients 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
|
||||
* @param bool $useSSL Whether to connect via SSL.
|
||||
* @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
|
||||
* @param string $host The HipChat server hostname.
|
||||
* @param string $token HipChat API Token
|
||||
* @param string $room The room that should be alerted of the message (Id or Name)
|
||||
* @param string $name Name used in the "from" field.
|
||||
* @param bool $notify Trigger a notification in clients 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
|
||||
* @param bool $useSSL Whether to connect via SSL.
|
||||
* @param string $format The format of the messages (default to text, can be set to html if you have html in the messages)
|
||||
* @param string $host The HipChat server hostname.
|
||||
*/
|
||||
public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text', $host = 'api.hipchat.com')
|
||||
{
|
||||
@@ -114,12 +114,12 @@ class HipChatHandler extends SocketHandler
|
||||
*/
|
||||
private function buildContent($record)
|
||||
{
|
||||
$dataArray = array(
|
||||
$dataArray = [
|
||||
'notify' => $this->notify ? 'true' : 'false',
|
||||
'message' => $record['formatted'],
|
||||
'message_format' => $this->format,
|
||||
'color' => $this->getAlertColor($record['level']),
|
||||
);
|
||||
];
|
||||
|
||||
if (!$this->validateStringLength($dataArray['message'], static::MAXIMUM_MESSAGE_LENGTH)) {
|
||||
if (function_exists('mb_substr')) {
|
||||
@@ -228,9 +228,9 @@ class HipChatHandler extends SocketHandler
|
||||
private function combineRecords($records)
|
||||
{
|
||||
$batchRecord = null;
|
||||
$batchRecords = array();
|
||||
$messages = array();
|
||||
$formattedMessages = array();
|
||||
$batchRecords = [];
|
||||
$messages = [];
|
||||
$formattedMessages = [];
|
||||
$level = 0;
|
||||
$levelName = null;
|
||||
$datetime = null;
|
||||
@@ -252,12 +252,12 @@ class HipChatHandler extends SocketHandler
|
||||
$formattedMessages[] = $this->getFormatter()->format($record);
|
||||
$formattedMessageStr = implode('', $formattedMessages);
|
||||
|
||||
$batchRecord = array(
|
||||
$batchRecord = [
|
||||
'message' => $messageStr,
|
||||
'formatted' => $formattedMessageStr,
|
||||
'context' => array(),
|
||||
'extra' => array(),
|
||||
);
|
||||
'context' => [],
|
||||
'extra' => [],
|
||||
];
|
||||
|
||||
if (!$this->validateStringLength($batchRecord['formatted'], static::MAXIMUM_MESSAGE_LENGTH)) {
|
||||
// Pop the last message and implode the remaining messages
|
||||
@@ -267,8 +267,8 @@ class HipChatHandler extends SocketHandler
|
||||
$batchRecord['formatted'] = implode('', $formattedMessages);
|
||||
|
||||
$batchRecords[] = $batchRecord;
|
||||
$messages = array($lastMessage);
|
||||
$formattedMessages = array($lastFormattedMessage);
|
||||
$messages = [$lastMessage];
|
||||
$formattedMessages = [$lastFormattedMessage];
|
||||
|
||||
$batchRecord = null;
|
||||
}
|
||||
@@ -282,11 +282,11 @@ class HipChatHandler extends SocketHandler
|
||||
foreach ($batchRecords as &$batchRecord) {
|
||||
$batchRecord = array_merge(
|
||||
$batchRecord,
|
||||
array(
|
||||
[
|
||||
'level' => $level,
|
||||
'level_name' => $levelName,
|
||||
'datetime' => $datetime,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ class IFTTTHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public function write(array $record)
|
||||
{
|
||||
$postData = array(
|
||||
$postData = [
|
||||
"value1" => $record["channel"],
|
||||
"value2" => $record["level_name"],
|
||||
"value3" => $record["message"],
|
||||
);
|
||||
];
|
||||
$postString = json_encode($postData);
|
||||
|
||||
$ch = curl_init();
|
||||
@@ -60,9 +60,9 @@ class IFTTTHandler extends AbstractProcessingHandler
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
));
|
||||
]);
|
||||
|
||||
Curl\Util::execute($ch);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class LogglyHandler extends AbstractProcessingHandler
|
||||
|
||||
protected $token;
|
||||
|
||||
protected $tag = array();
|
||||
protected $tag = [];
|
||||
|
||||
public function __construct($token, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
@@ -45,14 +45,14 @@ class LogglyHandler extends AbstractProcessingHandler
|
||||
|
||||
public function setTag($tag)
|
||||
{
|
||||
$tag = !empty($tag) ? $tag : array();
|
||||
$this->tag = is_array($tag) ? $tag : array($tag);
|
||||
$tag = !empty($tag) ? $tag : [];
|
||||
$this->tag = is_array($tag) ? $tag : [$tag];
|
||||
}
|
||||
|
||||
public function addTag($tag)
|
||||
{
|
||||
if (!empty($tag)) {
|
||||
$tag = is_array($tag) ? $tag : array($tag);
|
||||
$tag = is_array($tag) ? $tag : [$tag];
|
||||
$this->tag = array_unique(array_merge($this->tag, $tag));
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class LogglyHandler extends AbstractProcessingHandler
|
||||
{
|
||||
$url = sprintf("https://%s/%s/%s/", self::HOST, $endpoint, $this->token);
|
||||
|
||||
$headers = array('Content-Type: application/json');
|
||||
$headers = ['Content-Type: application/json'];
|
||||
|
||||
if (!empty($this->tag)) {
|
||||
$headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag);
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class MailHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
public function handleBatch(array $records)
|
||||
{
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
foreach ($records as $record) {
|
||||
if ($record['level'] < $this->level) {
|
||||
@@ -50,7 +50,7 @@ abstract class MailHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
protected function write(array $record)
|
||||
{
|
||||
$this->send((string) $record['formatted'], array($record));
|
||||
$this->send((string) $record['formatted'], [$record]);
|
||||
}
|
||||
|
||||
protected function getHighestRecord(array $records)
|
||||
|
||||
@@ -57,11 +57,11 @@ class MandrillHandler extends MailHandler
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
'key' => $this->apiKey,
|
||||
'raw_message' => (string) $message,
|
||||
'async' => false,
|
||||
)));
|
||||
]));
|
||||
|
||||
Curl\Util::execute($ch);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ class NativeMailerHandler extends MailHandler
|
||||
* Optional headers for the message
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = array();
|
||||
protected $headers = [];
|
||||
|
||||
/**
|
||||
* Optional parameters for the message
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters = array();
|
||||
protected $parameters = [];
|
||||
|
||||
/**
|
||||
* The wordwrap length for the message
|
||||
@@ -75,7 +75,7 @@ class NativeMailerHandler extends MailHandler
|
||||
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
$this->to = is_array($to) ? $to : array($to);
|
||||
$this->to = (array) $to;
|
||||
$this->subject = $subject;
|
||||
$this->addHeader(sprintf('From: %s', $from));
|
||||
$this->maxColumnWidth = $maxColumnWidth;
|
||||
|
||||
@@ -40,10 +40,10 @@ use PhpConsole\Helper;
|
||||
*/
|
||||
class PHPConsoleHandler extends AbstractProcessingHandler
|
||||
{
|
||||
private $options = array(
|
||||
private $options = [
|
||||
'enabled' => true, // bool Is PHP Console server enabled
|
||||
'classesPartialsTraceIgnore' => array('Monolog\\'), // array Hide calls of classes started with...
|
||||
'debugTagsKeysInContext' => array(0, 'tag'), // bool Is PHP Console server enabled
|
||||
'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with...
|
||||
'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled
|
||||
'useOwnErrorsHandler' => false, // bool Enable errors handling
|
||||
'useOwnExceptionsHandler' => false, // bool Enable exceptions handling
|
||||
'sourcesBasePath' => null, // string Base path of all project sources to strip in errors source paths
|
||||
@@ -52,7 +52,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
|
||||
'headersLimit' => null, // int|null Set headers size limit for your web-server
|
||||
'password' => null, // string|null Protect PHP Console connection by password
|
||||
'enableSslOnlyMode' => false, // bool Force connection by SSL for clients with PHP Console installed
|
||||
'ipMasks' => array(), // array Set IP masks of clients that will be allowed to connect to PHP Console: array('192.168.*.*', '127.0.0.1')
|
||||
'ipMasks' => [], // array Set IP masks of clients that will be allowed to connect to PHP Console: array('192.168.*.*', '127.0.0.1')
|
||||
'enableEvalListener' => false, // bool Enable eval request to be handled by eval dispatcher(if enabled, 'password' option is also required)
|
||||
'dumperDetectCallbacks' => false, // bool Convert callback items in dumper vars to (callback SomeClass::someMethod) strings
|
||||
'dumperLevelLimit' => 5, // int Maximum dumped vars array or object nested dump level
|
||||
@@ -61,7 +61,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
|
||||
'dumperDumpSizeLimit' => 500000, // int Maximum approximate size of dumped vars result formatted in JSON
|
||||
'detectDumpTraceAndSource' => false, // bool Autodetect and append trace data to debug
|
||||
'dataStorage' => null, // PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ)
|
||||
);
|
||||
];
|
||||
|
||||
/** @var Connector */
|
||||
private $connector;
|
||||
@@ -73,7 +73,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
|
||||
* @param bool $bubble
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(array $options = array(), Connector $connector = null, $level = Logger::DEBUG, $bubble = true)
|
||||
public function __construct(array $options = [], Connector $connector = null, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
if (!class_exists('PhpConsole\Connector')) {
|
||||
throw new Exception('PHP Console library not found. See https://github.com/barbushin/php-console#installation');
|
||||
|
||||
@@ -58,11 +58,11 @@ class ProcessHandler extends AbstractProcessingHandler
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $command Command for the process to start. Absolute paths are recommended,
|
||||
* especially if you do not use the $cwd parameter.
|
||||
* @param bool|int $level The minimum logging level at which this handler will be triggered.
|
||||
* @param bool|true $bubble Whether the messages that are handled can bubble up the stack or not.
|
||||
* @param string|null $cwd "Current working directory" (CWD) for the process to be executed in.
|
||||
* @param int $command Command for the process to start. Absolute paths are recommended,
|
||||
* especially if you do not use the $cwd parameter.
|
||||
* @param bool|int $level The minimum logging level at which this handler will be triggered.
|
||||
* @param bool|true $bubble Whether the messages that are handled can bubble up the stack or not.
|
||||
* @param string|null $cwd "Current working directory" (CWD) for the process to be executed in.
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null)
|
||||
@@ -83,7 +83,7 @@ class ProcessHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Writes the record down to the log of the implementing handler
|
||||
*
|
||||
* @param array $record
|
||||
* @param array $record
|
||||
* @throws \UnexpectedValueException
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ class PushoverHandler extends SocketHandler
|
||||
* @see https://pushover.net/api
|
||||
* @var array
|
||||
*/
|
||||
private $parameterNames = array(
|
||||
private $parameterNames = [
|
||||
'token' => true,
|
||||
'user' => true,
|
||||
'message' => true,
|
||||
@@ -51,18 +51,18 @@ class PushoverHandler extends SocketHandler
|
||||
'retry' => true,
|
||||
'expire' => true,
|
||||
'callback' => true,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Sounds the api supports by default
|
||||
* @see https://pushover.net/api#sounds
|
||||
* @var array
|
||||
*/
|
||||
private $sounds = array(
|
||||
private $sounds = [
|
||||
'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming',
|
||||
'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb',
|
||||
'persistent', 'echo', 'updown', 'none',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $token Pushover api token
|
||||
@@ -110,13 +110,13 @@ class PushoverHandler extends SocketHandler
|
||||
|
||||
$timestamp = $record['datetime']->getTimestamp();
|
||||
|
||||
$dataArray = array(
|
||||
$dataArray = [
|
||||
'token' => $this->token,
|
||||
'user' => $this->user,
|
||||
'message' => $message,
|
||||
'title' => $this->title,
|
||||
'timestamp' => $timestamp,
|
||||
);
|
||||
];
|
||||
|
||||
if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) {
|
||||
$dataArray['priority'] = 2;
|
||||
|
||||
@@ -27,7 +27,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Translates Monolog log levels to Raven log levels.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
private $logLevels = [
|
||||
Logger::DEBUG => Raven_Client::DEBUG,
|
||||
Logger::INFO => Raven_Client::INFO,
|
||||
Logger::NOTICE => Raven_Client::INFO,
|
||||
@@ -36,7 +36,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
Logger::CRITICAL => Raven_Client::FATAL,
|
||||
Logger::ALERT => Raven_Client::FATAL,
|
||||
Logger::EMERGENCY => Raven_Client::FATAL,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string should represent the current version of the calling
|
||||
@@ -92,7 +92,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
});
|
||||
|
||||
// the other ones are added as a context item
|
||||
$logs = array();
|
||||
$logs = [];
|
||||
foreach ($records as $r) {
|
||||
$logs[] = $this->processRecord($r);
|
||||
}
|
||||
@@ -134,9 +134,9 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
protected function write(array $record)
|
||||
{
|
||||
$previousUserContext = false;
|
||||
$options = array();
|
||||
$options = [];
|
||||
$options['level'] = $this->logLevels[$record['level']];
|
||||
$options['tags'] = array();
|
||||
$options['tags'] = [];
|
||||
if (!empty($record['extra']['tags'])) {
|
||||
$options['tags'] = array_merge($options['tags'], $record['extra']['tags']);
|
||||
unset($record['extra']['tags']);
|
||||
@@ -156,7 +156,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
$options['logger'] = $record['channel'];
|
||||
}
|
||||
foreach ($this->getExtraParameters() as $key) {
|
||||
foreach (array('extra', 'context') as $source) {
|
||||
foreach (['extra', 'context'] as $source) {
|
||||
if (!empty($record[$source][$key])) {
|
||||
$options[$key] = $record[$source][$key];
|
||||
unset($record[$source][$key]);
|
||||
@@ -183,7 +183,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
$options['extra']['message'] = $record['formatted'];
|
||||
$this->ravenClient->captureException($record['context']['exception'], $options);
|
||||
} else {
|
||||
$this->ravenClient->captureMessage($record['formatted'], array(), $options);
|
||||
$this->ravenClient->captureMessage($record['formatted'], [], $options);
|
||||
}
|
||||
|
||||
if ($previousUserContext !== false) {
|
||||
@@ -216,7 +216,7 @@ class RavenHandler extends AbstractProcessingHandler
|
||||
*/
|
||||
protected function getExtraParameters()
|
||||
{
|
||||
return array('checksum', 'release');
|
||||
return ['checksum', 'release'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ class RollbarHandler extends AbstractProcessingHandler
|
||||
$exception = $context['exception'];
|
||||
unset($context['exception']);
|
||||
|
||||
$payload = array();
|
||||
$payload = [];
|
||||
if (isset($context['payload'])) {
|
||||
$payload = $context['payload'];
|
||||
unset($context['payload']);
|
||||
@@ -69,14 +69,14 @@ class RollbarHandler extends AbstractProcessingHandler
|
||||
|
||||
$this->rollbarNotifier->report_exception($exception, $context, $payload);
|
||||
} else {
|
||||
$extraData = array(
|
||||
$extraData = [
|
||||
'level' => $record['level'],
|
||||
'channel' => $record['channel'],
|
||||
'datetime' => $record['datetime']->format('U'),
|
||||
);
|
||||
];
|
||||
|
||||
$context = $record['context'];
|
||||
$payload = array();
|
||||
$payload = [];
|
||||
if (isset($context['payload'])) {
|
||||
$payload = $context['payload'];
|
||||
unset($context['payload']);
|
||||
|
||||
@@ -69,7 +69,7 @@ class RotatingFileHandler extends StreamHandler
|
||||
|
||||
public function setFilenameFormat($filenameFormat, $dateFormat)
|
||||
{
|
||||
if (!in_array($dateFormat, array(self::FILE_PER_DAY, self::FILE_PER_MONTH, self::FILE_PER_YEAR))) {
|
||||
if (!in_array($dateFormat, [self::FILE_PER_DAY, self::FILE_PER_MONTH, self::FILE_PER_YEAR])) {
|
||||
throw new InvalidArgumentException(
|
||||
'Invalid date format - format must be one of '.
|
||||
'RotatingFileHandler::FILE_PER_DAY, RotatingFileHandler::FILE_PER_MONTH '.
|
||||
@@ -147,8 +147,8 @@ class RotatingFileHandler extends StreamHandler
|
||||
{
|
||||
$fileInfo = pathinfo($this->filename);
|
||||
$timedFilename = str_replace(
|
||||
array('{filename}', '{date}'),
|
||||
array($fileInfo['filename'], date($this->dateFormat)),
|
||||
['{filename}', '{date}'],
|
||||
[$fileInfo['filename'], date($this->dateFormat)],
|
||||
$fileInfo['dirname'] . '/' . $this->filenameFormat
|
||||
);
|
||||
|
||||
@@ -163,8 +163,8 @@ class RotatingFileHandler extends StreamHandler
|
||||
{
|
||||
$fileInfo = pathinfo($this->filename);
|
||||
$glob = str_replace(
|
||||
array('{filename}', '{date}'),
|
||||
array($fileInfo['filename'], '*'),
|
||||
['{filename}', '{date}'],
|
||||
[$fileInfo['filename'], '*'],
|
||||
$fileInfo['dirname'] . '/' . $this->filenameFormat
|
||||
);
|
||||
if (!empty($fileInfo['extension'])) {
|
||||
|
||||
@@ -51,13 +51,13 @@ class SendGridHandler extends MailHandler
|
||||
protected $subject;
|
||||
|
||||
/**
|
||||
* @param string $apiUser The SendGrid API User
|
||||
* @param string $apiKey The SendGrid API Key
|
||||
* @param string $from The sender of the email
|
||||
* @param string|array $to The recipients of the email
|
||||
* @param string $subject The subject of the mail
|
||||
* @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
|
||||
* @param string $apiUser The SendGrid API User
|
||||
* @param string $apiKey The SendGrid API Key
|
||||
* @param string $from The sender of the email
|
||||
* @param string|array $to The recipients of the email
|
||||
* @param string $subject The subject of the mail
|
||||
* @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(string $apiUser, string $apiKey, string $from, $to, string $subject, int $level = Logger::ERROR, bool $bubble = true)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ class SendGridHandler extends MailHandler
|
||||
*/
|
||||
protected function send($content, array $records)
|
||||
{
|
||||
$message = array();
|
||||
$message = [];
|
||||
$message['api_user'] = $this->apiUser;
|
||||
$message['api_key'] = $this->apiKey;
|
||||
$message['from'] = $this->from;
|
||||
|
||||
@@ -136,20 +136,20 @@ class SlackHandler extends SocketHandler
|
||||
*/
|
||||
protected function prepareContentData($record)
|
||||
{
|
||||
$dataArray = array(
|
||||
$dataArray = [
|
||||
'token' => $this->token,
|
||||
'channel' => $this->channel,
|
||||
'username' => $this->username,
|
||||
'text' => '',
|
||||
'attachments' => array(),
|
||||
);
|
||||
'attachments' => [],
|
||||
];
|
||||
|
||||
if ($this->useAttachment) {
|
||||
$attachment = array(
|
||||
$attachment = [
|
||||
'fallback' => $record['message'],
|
||||
'color' => $this->getAttachmentColor($record['level']),
|
||||
'fields' => array(),
|
||||
);
|
||||
'fields' => [],
|
||||
];
|
||||
|
||||
if ($this->useShortAttachment) {
|
||||
$attachment['title'] = $record['level_name'];
|
||||
@@ -157,54 +157,54 @@ class SlackHandler extends SocketHandler
|
||||
} else {
|
||||
$attachment['title'] = 'Message';
|
||||
$attachment['text'] = $record['message'];
|
||||
$attachment['fields'][] = array(
|
||||
$attachment['fields'][] = [
|
||||
'title' => 'Level',
|
||||
'value' => $record['level_name'],
|
||||
'short' => true,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->includeContextAndExtra) {
|
||||
if (!empty($record['extra'])) {
|
||||
if ($this->useShortAttachment) {
|
||||
$attachment['fields'][] = array(
|
||||
$attachment['fields'][] = [
|
||||
'title' => "Extra",
|
||||
'value' => $this->stringify($record['extra']),
|
||||
'short' => $this->useShortAttachment,
|
||||
);
|
||||
];
|
||||
} else {
|
||||
// Add all extra fields as individual fields in attachment
|
||||
foreach ($record['extra'] as $var => $val) {
|
||||
$attachment['fields'][] = array(
|
||||
$attachment['fields'][] = [
|
||||
'title' => $var,
|
||||
'value' => $val,
|
||||
'short' => $this->useShortAttachment,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($record['context'])) {
|
||||
if ($this->useShortAttachment) {
|
||||
$attachment['fields'][] = array(
|
||||
$attachment['fields'][] = [
|
||||
'title' => "Context",
|
||||
'value' => $this->stringify($record['context']),
|
||||
'short' => $this->useShortAttachment,
|
||||
);
|
||||
];
|
||||
} else {
|
||||
// Add all context fields as individual fields in attachment
|
||||
foreach ($record['context'] as $var => $val) {
|
||||
$attachment['fields'][] = array(
|
||||
$attachment['fields'][] = [
|
||||
'title' => $var,
|
||||
'value' => $val,
|
||||
'short' => $this->useShortAttachment,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dataArray['attachments'] = json_encode(array($attachment));
|
||||
$dataArray['attachments'] = json_encode([$attachment]);
|
||||
} else {
|
||||
$dataArray['text'] = $record['message'];
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class StreamHandler extends AbstractProcessingHandler
|
||||
}
|
||||
$this->createDir();
|
||||
$this->errorMessage = null;
|
||||
set_error_handler(array($this, 'customErrorHandler'));
|
||||
set_error_handler([$this, 'customErrorHandler']);
|
||||
$this->stream = fopen($this->url, 'a');
|
||||
if ($this->filePermission !== null) {
|
||||
@chmod($this->url, $this->filePermission);
|
||||
@@ -144,7 +144,7 @@ class StreamHandler extends AbstractProcessingHandler
|
||||
$dir = $this->getDirFromStream($this->url);
|
||||
if (null !== $dir && !is_dir($dir)) {
|
||||
$this->errorMessage = null;
|
||||
set_error_handler(array($this, 'customErrorHandler'));
|
||||
set_error_handler([$this, 'customErrorHandler']);
|
||||
$status = mkdir($dir, 0777, true);
|
||||
restore_error_handler();
|
||||
if (false === $status) {
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace Monolog\Handler;
|
||||
*/
|
||||
class TestHandler extends AbstractProcessingHandler
|
||||
{
|
||||
protected $records = array();
|
||||
protected $recordsByLevel = array();
|
||||
protected $records = [];
|
||||
protected $recordsByLevel = [];
|
||||
|
||||
public function getRecords()
|
||||
{
|
||||
@@ -75,8 +75,8 @@ class TestHandler extends AbstractProcessingHandler
|
||||
|
||||
public function clear()
|
||||
{
|
||||
$this->records = array();
|
||||
$this->recordsByLevel = array();
|
||||
$this->records = [];
|
||||
$this->recordsByLevel = [];
|
||||
}
|
||||
|
||||
protected function hasRecordRecords($level)
|
||||
@@ -145,7 +145,7 @@ class TestHandler extends AbstractProcessingHandler
|
||||
if (method_exists($this, $genericMethod)) {
|
||||
$args[] = $level;
|
||||
|
||||
return call_user_func_array(array($this, $genericMethod), $args);
|
||||
return call_user_func_array([$this, $genericMethod], $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $levelMap = array(
|
||||
protected $levelMap = [
|
||||
Logger::DEBUG => 1,
|
||||
Logger::INFO => 2,
|
||||
Logger::NOTICE => 3,
|
||||
@@ -35,7 +35,7 @@ class ZendMonitorHandler extends AbstractProcessingHandler
|
||||
Logger::CRITICAL => 6,
|
||||
Logger::ALERT => 7,
|
||||
Logger::EMERGENCY => 0,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Construct
|
||||
|
||||
@@ -152,7 +152,7 @@ class Logger implements LoggerInterface
|
||||
* @param callable[] $processors Optional array of processors
|
||||
* @param DateTimeZone $timezone Optional timezone, if not provided date_default_timezone_get() will be used
|
||||
*/
|
||||
public function __construct(string $name, array $handlers = array(), array $processors = array(), DateTimeZone $timezone = null)
|
||||
public function __construct(string $name, array $handlers = [], array $processors = [], DateTimeZone $timezone = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->handlers = $handlers;
|
||||
@@ -218,7 +218,7 @@ class Logger implements LoggerInterface
|
||||
*/
|
||||
public function setHandlers(array $handlers): self
|
||||
{
|
||||
$this->handlers = array();
|
||||
$this->handlers = [];
|
||||
foreach (array_reverse($handlers) as $handler) {
|
||||
$this->pushHandler($handler);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addRecord(int $level, string $message, array $context = array()): bool
|
||||
public function addRecord(int $level, string $message, array $context = []): bool
|
||||
{
|
||||
$levelName = static::getLevelName($level);
|
||||
|
||||
@@ -303,7 +303,7 @@ class Logger implements LoggerInterface
|
||||
$handlerKey = null;
|
||||
reset($this->handlers);
|
||||
while ($handler = current($this->handlers)) {
|
||||
if ($handler->isHandling(array('level' => $level))) {
|
||||
if ($handler->isHandling(['level' => $level])) {
|
||||
$handlerKey = key($this->handlers);
|
||||
break;
|
||||
}
|
||||
@@ -317,15 +317,15 @@ class Logger implements LoggerInterface
|
||||
|
||||
$ts = $this->createDateTime();
|
||||
|
||||
$record = array(
|
||||
$record = [
|
||||
'message' => $message,
|
||||
'context' => $context,
|
||||
'level' => $level,
|
||||
'level_name' => $levelName,
|
||||
'channel' => $this->name,
|
||||
'datetime' => $ts,
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
|
||||
foreach ($this->processors as $processor) {
|
||||
$record = call_user_func($processor, $record);
|
||||
@@ -394,9 +394,9 @@ class Logger implements LoggerInterface
|
||||
*/
|
||||
public function isHandling(int $level): bool
|
||||
{
|
||||
$record = array(
|
||||
$record = [
|
||||
'level' => $level,
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($this->handlers as $handler) {
|
||||
if ($handler->isHandling($record)) {
|
||||
@@ -417,7 +417,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
$level = static::toMonologLevel($level);
|
||||
|
||||
@@ -433,7 +433,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function debug($message, array $context = array())
|
||||
public function debug($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::DEBUG, (string) $message, $context);
|
||||
}
|
||||
@@ -447,7 +447,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function info($message, array $context = array())
|
||||
public function info($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::INFO, (string) $message, $context);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function notice($message, array $context = array())
|
||||
public function notice($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::NOTICE, (string) $message, $context);
|
||||
}
|
||||
@@ -475,7 +475,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function warning($message, array $context = array())
|
||||
public function warning($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::WARNING, (string) $message, $context);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function error($message, array $context = array())
|
||||
public function error($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::ERROR, (string) $message, $context);
|
||||
}
|
||||
@@ -503,7 +503,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function critical($message, array $context = array())
|
||||
public function critical($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::CRITICAL, (string) $message, $context);
|
||||
}
|
||||
@@ -517,7 +517,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function alert($message, array $context = array())
|
||||
public function alert($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::ALERT, (string) $message, $context);
|
||||
}
|
||||
@@ -531,7 +531,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function emergency($message, array $context = array())
|
||||
public function emergency($message, array $context = [])
|
||||
{
|
||||
return $this->addRecord(static::EMERGENCY, (string) $message, $context);
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ class GitProcessor
|
||||
|
||||
$branches = `git branch -v --no-abbrev`;
|
||||
if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) {
|
||||
return self::$cache = array(
|
||||
return self::$cache = [
|
||||
'branch' => $matches[1],
|
||||
'commit' => $matches[2],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return self::$cache = array();
|
||||
return self::$cache = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,15 @@ class IntrospectionProcessor
|
||||
|
||||
private $skipStackFramesCount;
|
||||
|
||||
private $skipFunctions = array(
|
||||
private $skipFunctions = [
|
||||
'call_user_func',
|
||||
'call_user_func_array',
|
||||
);
|
||||
];
|
||||
|
||||
public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0)
|
||||
public function __construct($level = Logger::DEBUG, array $skipClassesPartials = [], $skipStackFramesCount = 0)
|
||||
{
|
||||
$this->level = Logger::toMonologLevel($level);
|
||||
$this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials);
|
||||
$this->skipClassesPartials = array_merge(['Monolog\\'], $skipClassesPartials);
|
||||
$this->skipStackFramesCount = $skipStackFramesCount;
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ class IntrospectionProcessor
|
||||
// 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;
|
||||
|
||||
@@ -30,7 +30,7 @@ class PsrLogMessageProcessor
|
||||
return $record;
|
||||
}
|
||||
|
||||
$replacements = array();
|
||||
$replacements = [];
|
||||
foreach ($record['context'] as $key => $val) {
|
||||
if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) {
|
||||
$replacements['{'.$key.'}'] = $val;
|
||||
|
||||
@@ -20,17 +20,17 @@ class TagProcessor
|
||||
{
|
||||
private $tags;
|
||||
|
||||
public function __construct(array $tags = array())
|
||||
public function __construct(array $tags = [])
|
||||
{
|
||||
$this->setTags($tags);
|
||||
}
|
||||
|
||||
public function addTags(array $tags = array())
|
||||
public function addTags(array $tags = [])
|
||||
{
|
||||
$this->tags = array_merge($this->tags, $tags);
|
||||
}
|
||||
|
||||
public function setTags(array $tags = array())
|
||||
public function setTags(array $tags = [])
|
||||
{
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ class WebProcessor
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $extraFields = array(
|
||||
protected $extraFields = [
|
||||
'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
|
||||
|
||||
@@ -42,7 +42,7 @@ class Registry
|
||||
*
|
||||
* @var Logger[]
|
||||
*/
|
||||
private static $loggers = array();
|
||||
private static $loggers = [];
|
||||
|
||||
/**
|
||||
* Adds new logging channel to the registry
|
||||
@@ -100,7 +100,7 @@ class Registry
|
||||
*/
|
||||
public static function clear()
|
||||
{
|
||||
self::$loggers = array();
|
||||
self::$loggers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,17 +24,17 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @return array Record
|
||||
*/
|
||||
protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
|
||||
protected function getRecord($level = Logger::WARNING, $message = 'test', $context = [])
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'message' => $message,
|
||||
'context' => $context,
|
||||
'level' => $level,
|
||||
'level_name' => Logger::getLevelName($level),
|
||||
'channel' => 'test',
|
||||
'datetime' => new DateTimeImmutable(true),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,13 +42,13 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function getMultipleRecords()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
||||
$this->getRecord(Logger::INFO, 'information'),
|
||||
$this->getRecord(Logger::WARNING, 'warning'),
|
||||
$this->getRecord(Logger::ERROR, 'error'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user