mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 12:31:15 +01:00
Cleanup logger
This commit is contained in:
parent
3c4fa8badd
commit
34867f9d20
2
bot.php
2
bot.php
@ -13,7 +13,7 @@ If not, see <http://www.gnu.org/licenses/>.
|
||||
set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/'));
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'connection_settings' => ['all' => ['protocol' => 'tcp_abridged', 'pfs' => true]]];
|
||||
$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']];//, 'connection_settings' => ['all' => ['test_mode' => true]]];
|
||||
|
||||
try {
|
||||
$MadelineProto = new \danog\MadelineProto\API('bot.madeline');
|
||||
|
@ -49,9 +49,7 @@ class API extends APIFactory
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
if (Logger::$constructed) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
}
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized);
|
||||
}
|
||||
|
@ -37,9 +37,7 @@ class Exception extends \Exception
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
if (\danog\MadelineProto\Logger::$constructed) {
|
||||
\danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
if (in_array($message, ['The session is corrupted!', 'Re-executing query...', 'I had to recreate the temporary authorization key', 'This peer is not present in the internal peer database', "Couldn't get response", 'Chat forbidden', 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', 'File does not exist', 'Please install this fork of phpseclib: https://github.com/danog/phpseclib'])) {
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ class Logger
|
||||
public static $storage = [];
|
||||
public static $mode = 1;
|
||||
public static $optional = null;
|
||||
public static $constructed = false;
|
||||
public static $prefix = '';
|
||||
public static $level = 3;
|
||||
public static $has_thread = false;
|
||||
@ -150,7 +149,6 @@ class Logger
|
||||
}
|
||||
self::$mode = $mode;
|
||||
self::$optional = $optional;
|
||||
self::$constructed = true;
|
||||
self::$prefix = $prefix === '' ? '' : ', '.$prefix;
|
||||
self::$level = $level;
|
||||
self::class_exists();
|
||||
@ -164,9 +162,7 @@ class Logger
|
||||
if ($level > self::$level) {
|
||||
return false;
|
||||
}
|
||||
if (!self::$constructed) {
|
||||
// throw new Exception(\danog\MadelineProto\Lang::$current_lang['constructor_function_uncalled']);
|
||||
}
|
||||
|
||||
$prefix = self::$prefix;
|
||||
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
|
||||
$prefix .= ' (t)';
|
||||
|
@ -103,9 +103,7 @@ class Serialization
|
||||
} catch (\danog\MadelineProto\Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($tounserialize);
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
if (Logger::$constructed) {
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
}
|
||||
Logger::log([(string) $e], Logger::ERROR);
|
||||
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) {
|
||||
$tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user