Enable PHP logging

This commit is contained in:
Daniil Gentili 2018-12-27 21:22:47 +01:00
parent 812dc89bc2
commit 79b0e647f5
2 changed files with 11 additions and 1 deletions

View File

@ -517,6 +517,7 @@ class MTProto implements TLCallback
$app_version = '4.9.1 (13613)';
}
$backtrace = debug_backtrace(0);
$this->altervista = isset($_SERVER['SERVER_ADMIN']) && strpos($_SERVER['SERVER_ADMIN'], 'altervista.org');
// Set default settings
@ -641,7 +642,7 @@ class MTProto implements TLCallback
* $message is an array containing the messages the log, $level, is the logging level
*/
// write to
'logger_param' => getcwd().'/MadelineProto.log',
'logger_param' => dirname(end($backtrace)['file']).'/MadelineProto.log',
'logger' => php_sapi_name() === 'cli' ? 3 : 2,
// overwrite previous setting and echo logs
'logger_level' => Logger::VERBOSE,

View File

@ -49,6 +49,15 @@ trait Loop
set_time_limit(-1);
} catch (\danog\MadelineProto\Exception $e) {
$backtrace = debug_backtrace(0);
try {
error_reporting(E_ALL);
ini_set("log_errors", 1);
ini_set("error_log", dirname(end($backtrace)['file'])."/MadelineProto.log");
error_log('Enabled PHP logging');
} catch (\danog\MadelineProto\Exception $e) {
$this->logger->logger("Could not enable PHP logging");
}
$lockfile = dirname(end($backtrace)['file']).'/bot.lock';
unset($backtrace);
$try_locking = true;