-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [FIX] Исправлена (https://skripters.biz/forum/threads/dle-api.50709/post-499483)[заявленная ошибка], - [FIX] Исправлена (https://skripters.biz/forum/threads/dle-api.50709/post-499640)[заявленная ошибка]
- Loading branch information
Showing
14 changed files
with
736 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
upload/api/vendor/monolog/monolog/src/Monolog/Formatter/SyslogFormatter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
* 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\Formatter; | ||
|
||
use Monolog\Level; | ||
use Monolog\LogRecord; | ||
|
||
/** | ||
* Serializes a log message according to RFC 5424 | ||
* | ||
* @author Dalibor Karlović <dalibor.karlovic@sigwin.hr> | ||
* @author Renat Gabdullin <renatobyj@gmail.com> | ||
*/ | ||
class SyslogFormatter extends LineFormatter | ||
{ | ||
private const SYSLOG_FACILITY_USER = 1; | ||
private const FORMAT = "<%extra.priority%>1 %datetime% %extra.hostname% %extra.app-name% %extra.procid% %channel% %extra.structured-data% %level_name%: %message% %context% %extra%\n"; | ||
private const NILVALUE = '-'; | ||
|
||
private string $hostname; | ||
private int $procid; | ||
|
||
public function __construct(private string $applicationName = self::NILVALUE) | ||
{ | ||
parent::__construct(self::FORMAT, 'Y-m-d\TH:i:s.uP', true, true); | ||
$this->hostname = (string) gethostname(); | ||
$this->procid = (int) getmypid(); | ||
} | ||
|
||
public function format(LogRecord $record): string | ||
{ | ||
$record->extra = $this->formatExtra($record); | ||
|
||
return parent::format($record); | ||
} | ||
|
||
/** | ||
* @param LogRecord $record | ||
* @return array<string, mixed> | ||
*/ | ||
private function formatExtra(LogRecord $record): array | ||
{ | ||
$extra = $record->extra; | ||
$extra['app-name'] = $this->applicationName; | ||
$extra['hostname'] = $this->hostname; | ||
$extra['procid'] = $this->procid; | ||
$extra['priority'] = self::calculatePriority($record->level); | ||
$extra['structured-data'] = self::NILVALUE; | ||
|
||
return $extra; | ||
} | ||
|
||
private static function calculatePriority(Level $level): int | ||
{ | ||
return (self::SYSLOG_FACILITY_USER * 8) + $level->toRFC5424Level(); | ||
} | ||
} |
209 changes: 209 additions & 0 deletions
209
upload/api/vendor/monolog/monolog/src/Monolog/Level.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
* 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; | ||
|
||
use Psr\Log\LogLevel; | ||
|
||
/** | ||
* Represents the log levels | ||
* | ||
* Monolog supports the logging levels described by RFC 5424 {@see https://datatracker.ietf.org/doc/html/rfc5424} | ||
* but due to BC the severity values used internally are not 0-7. | ||
* | ||
* To get the level name/value out of a Level there are several options: | ||
* | ||
* - Use ->getName() to get the standard Monolog name which is full uppercased (e.g. "DEBUG") | ||
* - Use ->toPsrLogLevel() to get the standard PSR-3 name which is full lowercased (e.g. "debug") | ||
* - Use ->toRFC5424Level() to get the standard RFC 5424 value (e.g. 7 for debug, 0 for emergency) | ||
* - Use ->name to get the enum case's name which is capitalized (e.g. "Debug") | ||
* | ||
* To get the internal value for filtering, if the includes/isLowerThan/isHigherThan methods are | ||
* not enough, you can use ->value to get the enum case's integer value. | ||
*/ | ||
enum Level: int | ||
{ | ||
/** | ||
* Detailed debug information | ||
*/ | ||
case Debug = 100; | ||
|
||
/** | ||
* Interesting events | ||
* | ||
* Examples: User logs in, SQL logs. | ||
*/ | ||
case Info = 200; | ||
|
||
/** | ||
* Uncommon events | ||
*/ | ||
case Notice = 250; | ||
|
||
/** | ||
* Exceptional occurrences that are not errors | ||
* | ||
* Examples: Use of deprecated APIs, poor use of an API, | ||
* undesirable things that are not necessarily wrong. | ||
*/ | ||
case Warning = 300; | ||
|
||
/** | ||
* Runtime errors | ||
*/ | ||
case Error = 400; | ||
|
||
/** | ||
* Critical conditions | ||
* | ||
* Example: Application component unavailable, unexpected exception. | ||
*/ | ||
case Critical = 500; | ||
|
||
/** | ||
* Action must be taken immediately | ||
* | ||
* Example: Entire website down, database unavailable, etc. | ||
* This should trigger the SMS alerts and wake you up. | ||
*/ | ||
case Alert = 550; | ||
|
||
/** | ||
* Urgent alert. | ||
*/ | ||
case Emergency = 600; | ||
|
||
/** | ||
* @param value-of<self::NAMES>|LogLevel::*|'Debug'|'Info'|'Notice'|'Warning'|'Error'|'Critical'|'Alert'|'Emergency' $name | ||
* @return static | ||
*/ | ||
public static function fromName(string $name): self | ||
{ | ||
return match ($name) { | ||
'debug', 'Debug', 'DEBUG' => self::Debug, | ||
'info', 'Info', 'INFO' => self::Info, | ||
'notice', 'Notice', 'NOTICE' => self::Notice, | ||
'warning', 'Warning', 'WARNING' => self::Warning, | ||
'error', 'Error', 'ERROR' => self::Error, | ||
'critical', 'Critical', 'CRITICAL' => self::Critical, | ||
'alert', 'Alert', 'ALERT' => self::Alert, | ||
'emergency', 'Emergency', 'EMERGENCY' => self::Emergency, | ||
}; | ||
} | ||
|
||
/** | ||
* @param value-of<self::VALUES> $value | ||
* @return static | ||
*/ | ||
public static function fromValue(int $value): self | ||
{ | ||
return self::from($value); | ||
} | ||
|
||
/** | ||
* Returns true if the passed $level is higher or equal to $this | ||
*/ | ||
public function includes(Level $level): bool | ||
{ | ||
return $this->value <= $level->value; | ||
} | ||
|
||
public function isHigherThan(Level $level): bool | ||
{ | ||
return $this->value > $level->value; | ||
} | ||
|
||
public function isLowerThan(Level $level): bool | ||
{ | ||
return $this->value < $level->value; | ||
} | ||
|
||
/** | ||
* Returns the monolog standardized all-capitals name of the level | ||
* | ||
* Use this instead of $level->name which returns the enum case name (e.g. Debug vs DEBUG if you use getName()) | ||
* | ||
* @return value-of<self::NAMES> | ||
*/ | ||
public function getName(): string | ||
{ | ||
return match ($this) { | ||
self::Debug => 'DEBUG', | ||
self::Info => 'INFO', | ||
self::Notice => 'NOTICE', | ||
self::Warning => 'WARNING', | ||
self::Error => 'ERROR', | ||
self::Critical => 'CRITICAL', | ||
self::Alert => 'ALERT', | ||
self::Emergency => 'EMERGENCY', | ||
}; | ||
} | ||
|
||
/** | ||
* Returns the PSR-3 level matching this instance | ||
* | ||
* @phpstan-return \Psr\Log\LogLevel::* | ||
*/ | ||
public function toPsrLogLevel(): string | ||
{ | ||
return match ($this) { | ||
self::Debug => LogLevel::DEBUG, | ||
self::Info => LogLevel::INFO, | ||
self::Notice => LogLevel::NOTICE, | ||
self::Warning => LogLevel::WARNING, | ||
self::Error => LogLevel::ERROR, | ||
self::Critical => LogLevel::CRITICAL, | ||
self::Alert => LogLevel::ALERT, | ||
self::Emergency => LogLevel::EMERGENCY, | ||
}; | ||
} | ||
|
||
/** | ||
* Returns the RFC 5424 level matching this instance | ||
* | ||
* @phpstan-return int<0, 7> | ||
*/ | ||
public function toRFC5424Level(): int | ||
{ | ||
return match ($this) { | ||
self::Debug => 7, | ||
self::Info => 6, | ||
self::Notice => 5, | ||
self::Warning => 4, | ||
self::Error => 3, | ||
self::Critical => 2, | ||
self::Alert => 1, | ||
self::Emergency => 0, | ||
}; | ||
} | ||
|
||
public const VALUES = [ | ||
100, | ||
200, | ||
250, | ||
300, | ||
400, | ||
500, | ||
550, | ||
600, | ||
]; | ||
|
||
public const NAMES = [ | ||
'DEBUG', | ||
'INFO', | ||
'NOTICE', | ||
'WARNING', | ||
'ERROR', | ||
'CRITICAL', | ||
'ALERT', | ||
'EMERGENCY', | ||
]; | ||
} |
51 changes: 51 additions & 0 deletions
51
upload/api/vendor/monolog/monolog/src/Monolog/Processor/ClosureContextProcessor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
* 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\LogRecord; | ||
|
||
/** | ||
* Generates a context from a Closure if the Closure is the only value | ||
* in the context | ||
* | ||
* It helps reduce the performance impact of debug logs if they do | ||
* need to create lots of context information. If this processor is added | ||
* on the correct handler the context data will only be generated | ||
* when the logs are actually logged to that handler, which is useful when | ||
* using FingersCrossedHandler or other filtering handlers to conditionally | ||
* log records. | ||
*/ | ||
class ClosureContextProcessor implements ProcessorInterface | ||
{ | ||
public function __invoke(LogRecord $record): LogRecord | ||
{ | ||
$context = $record->context; | ||
if (isset($context[0]) && 1 === \count($context) && $context[0] instanceof \Closure) { | ||
try { | ||
$context = $context[0](); | ||
} catch (\Throwable $e) { | ||
$context = [ | ||
'error_on_context_generation' => $e->getMessage(), | ||
'exception' => $e, | ||
]; | ||
} | ||
|
||
if (!\is_array($context)) { | ||
$context = [$context]; | ||
} | ||
|
||
$record = $record->with(context: $context); | ||
} | ||
|
||
return $record; | ||
} | ||
} |
Oops, something went wrong.