Logger and connection improvements
This commit is contained in:
parent
8b2caed419
commit
a376f0bf82
@ -98,13 +98,13 @@
|
||||
],
|
||||
"build": [
|
||||
"@docs",
|
||||
"@phpdocs",
|
||||
"@phpdoc",
|
||||
"@cs-fix",
|
||||
"@psalm"
|
||||
],
|
||||
"phpdocs": [
|
||||
"@phpdocsInternal",
|
||||
"@phpdocsMain"
|
||||
"phpdoc": [
|
||||
"@phpdocInternal",
|
||||
"@phpdocMain"
|
||||
],
|
||||
"check": [
|
||||
"@cs",
|
||||
@ -115,8 +115,8 @@
|
||||
"cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --dry-run",
|
||||
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff",
|
||||
"psalm": "psalm",
|
||||
"phpdocsMain": "php tools/phpdoc.php",
|
||||
"phpdocsInternal": "phpdoc docs/docs/PHPInternal",
|
||||
"phpdocMain": "php tools/phpdoc.php",
|
||||
"phpdocInternal": "phpdoc docs/docs/PHPInternal",
|
||||
"docs": "php tools/build_docs.php",
|
||||
"test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit --coverage-text --config tests/phpunit.xml"
|
||||
}
|
||||
|
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit e15b11644a7e763127ed6439ac0aec84944e288e
|
||||
Subproject commit 0510e69e08411194203f4034b6d4b3e3232aea75
|
@ -365,6 +365,7 @@ class DataCenter
|
||||
$extra = isset($this->dclist[$test][$ipv6][$dc_number]['secret']) ? ['secret' => $this->dclist[$test][$ipv6][$dc_number]['secret']] : [];
|
||||
$combos[] = [[DefaultStream::class, []], [BufferedRawStream::class, []], [ObfuscatedStream::class, $extra], [IntermediatePaddedStream::class, []]];
|
||||
}
|
||||
$proxyCombos = [];
|
||||
foreach ($this->settings->getProxies() as $proxy => $extras) {
|
||||
if (!$dc_number && $proxy === ObfuscatedStream::class) {
|
||||
continue;
|
||||
@ -373,7 +374,7 @@ class DataCenter
|
||||
if ($proxy === ObfuscatedStream::class && \in_array(\strlen($extra['secret']), [17, 34])) {
|
||||
$combos[] = [[DefaultStream::class, []], [BufferedRawStream::class, []], [$proxy, $extra], [IntermediatePaddedStream::class, []]];
|
||||
}
|
||||
foreach ($combos as $k => $orig) {
|
||||
foreach ($combos as $orig) {
|
||||
$combo = [];
|
||||
if ($proxy === ObfuscatedStream::class) {
|
||||
$combo = $orig;
|
||||
@ -386,21 +387,21 @@ class DataCenter
|
||||
}
|
||||
} else {
|
||||
if ($orig[1][0] === BufferedRawStream::class) {
|
||||
list($first, $second) = [\array_slice($orig, 0, 2), \array_slice($orig, 2)];
|
||||
[$first, $second] = [\array_slice($orig, 0, 2), \array_slice($orig, 2)];
|
||||
$first[] = [$proxy, $extra];
|
||||
$combo = \array_merge($first, $second);
|
||||
} elseif (\in_array($orig[1][0], [WsStream::class, WssStream::class])) {
|
||||
list($first, $second) = [\array_slice($orig, 0, 1), \array_slice($orig, 1)];
|
||||
[$first, $second] = [\array_slice($orig, 0, 1), \array_slice($orig, 1)];
|
||||
$first[] = [BufferedRawStream::class, []];
|
||||
$first[] = [$proxy, $extra];
|
||||
$combo = \array_merge($first, $second);
|
||||
}
|
||||
}
|
||||
\array_unshift($combos, $combo);
|
||||
//unset($combos[$k]);
|
||||
$proxyCombos []= $combo;
|
||||
}
|
||||
}
|
||||
}
|
||||
$combos = array_merge($proxyCombos, $combos);
|
||||
if ($dc_number) {
|
||||
$combos[] = [[DefaultStream::class, []], [BufferedRawStream::class, []], [HttpsStream::class, []]];
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ use function Amp\Mysql\Pool;
|
||||
|
||||
/**
|
||||
* MySQL driver wrapper.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Mysql
|
||||
{
|
||||
|
@ -11,6 +11,8 @@ use function Amp\Postgres\Pool;
|
||||
|
||||
/**
|
||||
* Postgres driver wrapper.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Postgres
|
||||
{
|
||||
|
@ -9,6 +9,8 @@ use danog\MadelineProto\Settings\Database\Redis as DatabaseRedis;
|
||||
|
||||
/**
|
||||
* Redis driver wrapper.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Redis
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ use danog\MadelineProto\Db\MysqlArray as DbMysqlArray;
|
||||
|
||||
/**
|
||||
* MySQL database backend, no caching.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MysqlArray extends DbMysqlArray
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ use danog\MadelineProto\Db\PostgresArray as DbPostgresArray;
|
||||
|
||||
/**
|
||||
* Postgres database backend, no caching.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PostgresArray extends DbPostgresArray
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ use danog\MadelineProto\Db\RedisArray as DbRedisArray;
|
||||
|
||||
/**
|
||||
* Redis database backend, no caching.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class RedisArray extends DbRedisArray
|
||||
{
|
||||
|
@ -278,15 +278,18 @@ class Logger
|
||||
Snitch::logFile($this->optional);
|
||||
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a'));
|
||||
if ($maxSize !== -1) {
|
||||
$optional = &$this->optional;
|
||||
$stdout = &$this->stdout;
|
||||
$this->rotateId = Loop::repeat(
|
||||
10*1000,
|
||||
function () use ($maxSize) {
|
||||
\clearstatcache(true, $this->optional);
|
||||
if (\file_exists($this->optional) && \filesize($this->optional) >= $maxSize) {
|
||||
$this->stdout = null;
|
||||
\unlink($this->optional);
|
||||
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a'));
|
||||
$this->logger("Automatically truncated logfile to $maxSize");
|
||||
static function () use ($maxSize, $optional, &$stdout) {
|
||||
\clearstatcache(true, $optional);
|
||||
if (\file_exists($optional) && \filesize($optional) >= $maxSize) {
|
||||
$stdout->close();
|
||||
$stdout = null;
|
||||
\unlink($optional);
|
||||
$stdout = new ResourceOutputStream(\fopen($optional, 'a'));
|
||||
self::log("Automatically truncated logfile to $maxSize");
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -303,9 +306,7 @@ class Logger
|
||||
}
|
||||
}
|
||||
|
||||
if (!self::$default) {
|
||||
self::$default = $this;
|
||||
}
|
||||
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||
try {
|
||||
\error_reporting(E_ALL);
|
||||
|
@ -52,6 +52,8 @@ use function Amp\File\size;
|
||||
|
||||
/**
|
||||
* Manages all of the mtproto stuff.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MTProto extends AsyncConstruct implements TLCallback
|
||||
{
|
||||
|
@ -21,6 +21,8 @@ namespace danog\MadelineProto\MTProtoTools;
|
||||
|
||||
/**
|
||||
* Stores multiple update states.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CombinedUpdatesState
|
||||
{
|
||||
|
@ -114,4 +114,6 @@ $filter = function (string $class) use ($ignore): bool {
|
||||
PhpDocBuilder::fromNamespace()
|
||||
->setFilter($filter)
|
||||
->setOutput(__DIR__.'/../docs/docs/PHP/')
|
||||
->setImage("https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png")
|
||||
->run();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user