mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Update to laravel 7
This commit is contained in:
@@ -27,20 +27,16 @@ interface DebugLoggerInterface
|
||||
* timestamp, message, priority, and priorityName.
|
||||
* It can also have an optional context key containing an array.
|
||||
*
|
||||
* @param Request|null $request The request to get logs for
|
||||
*
|
||||
* @return array An array of logs
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs(/* Request $request = null */);
|
||||
public function getLogs(Request $request = null);
|
||||
|
||||
/**
|
||||
* Returns the number of errors.
|
||||
*
|
||||
* @param Request|null $request The request to count logs for
|
||||
*
|
||||
* @return int The number of errors
|
||||
* @return int
|
||||
*/
|
||||
public function countErrors(/* Request $request = null */);
|
||||
public function countErrors(Request $request = null);
|
||||
|
||||
/**
|
||||
* Removes all log records.
|
||||
|
||||
42
vendor/symfony/http-kernel/Log/Logger.php
vendored
42
vendor/symfony/http-kernel/Log/Logger.php
vendored
@@ -22,7 +22,7 @@ use Psr\Log\LogLevel;
|
||||
*/
|
||||
class Logger extends AbstractLogger
|
||||
{
|
||||
private static $levels = [
|
||||
private const LEVELS = [
|
||||
LogLevel::DEBUG => 0,
|
||||
LogLevel::INFO => 1,
|
||||
LogLevel::NOTICE => 2,
|
||||
@@ -35,15 +35,20 @@ class Logger extends AbstractLogger
|
||||
|
||||
private $minLevelIndex;
|
||||
private $formatter;
|
||||
|
||||
/** @var resource|null */
|
||||
private $handle;
|
||||
|
||||
public function __construct(string $minLevel = null, $output = 'php://stderr', callable $formatter = null)
|
||||
/**
|
||||
* @param string|resource|null $output
|
||||
*/
|
||||
public function __construct(string $minLevel = null, $output = null, callable $formatter = null)
|
||||
{
|
||||
if (null === $minLevel) {
|
||||
$minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING;
|
||||
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
|
||||
|
||||
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
|
||||
switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) {
|
||||
switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
|
||||
case -1: $minLevel = LogLevel::ERROR; break;
|
||||
case 1: $minLevel = LogLevel::NOTICE; break;
|
||||
case 2: $minLevel = LogLevel::INFO; break;
|
||||
@@ -52,37 +57,43 @@ class Logger extends AbstractLogger
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset(self::$levels[$minLevel])) {
|
||||
if (!isset(self::LEVELS[$minLevel])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $minLevel));
|
||||
}
|
||||
|
||||
$this->minLevelIndex = self::$levels[$minLevel];
|
||||
$this->minLevelIndex = self::LEVELS[$minLevel];
|
||||
$this->formatter = $formatter ?: [$this, 'format'];
|
||||
if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
|
||||
if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
|
||||
throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
if (!isset(self::$levels[$level])) {
|
||||
if (!isset(self::LEVELS[$level])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
|
||||
}
|
||||
|
||||
if (self::$levels[$level] < $this->minLevelIndex) {
|
||||
if (self::LEVELS[$level] < $this->minLevelIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
$formatter = $this->formatter;
|
||||
fwrite($this->handle, $formatter($level, $message, $context));
|
||||
if ($this->handle) {
|
||||
@fwrite($this->handle, $formatter($level, $message, $context));
|
||||
} else {
|
||||
error_log($formatter($level, $message, $context, false));
|
||||
}
|
||||
}
|
||||
|
||||
private function format(string $level, string $message, array $context): string
|
||||
private function format(string $level, string $message, array $context, bool $prefixDate = true): string
|
||||
{
|
||||
if (false !== strpos($message, '{')) {
|
||||
if (str_contains($message, '{')) {
|
||||
$replacements = [];
|
||||
foreach ($context as $key => $val) {
|
||||
if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
|
||||
@@ -99,6 +110,11 @@ class Logger extends AbstractLogger
|
||||
$message = strtr($message, $replacements);
|
||||
}
|
||||
|
||||
return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).\PHP_EOL;
|
||||
$log = sprintf('[%s] %s', $level, $message).\PHP_EOL;
|
||||
if ($prefixDate) {
|
||||
$log = date(\DateTime::RFC3339).' '.$log;
|
||||
}
|
||||
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user