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