Improve logging

This commit is contained in:
Daniil Gentili 2017-04-30 12:57:40 +02:00
parent e404767a06
commit b67d876dee
5 changed files with 9 additions and 8 deletions

View File

@ -1,2 +1,2 @@
script:
- curl https://api.rollbar.com/api/1/deploy/ -F access_token=31979a2053e045548573d29232dde9c5 -F environment=production -F revision=`git log -n 1 --pretty=format:"%H"` -F local_username=$USER
- curl https://api.rollbar.com/api/1/deploy/ -F access_token=f9fff6689aea4905b58eec73f66c791d -F environment=production -F revision=`git log -n 1 --pretty=format:"%H"` -F local_username=$USER

View File

@ -32,7 +32,7 @@ class Exception extends \Exception
if (strpos($message, 'Received request to switch to DC ') !== false) {
return;
}
\Rollbar\Rollbar::log($this, debug_backtrace(), 'error');
\Rollbar\Rollbar::log(\Rollbar\Payload\Level::error(), $this, debug_backtrace(0));
}
/**

View File

@ -327,6 +327,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
'logger_param' => '/tmp/MadelineProto.log',
'logger' => 3, // overwrite previous setting and echo logs
'logger_level' => Logger::VERBOSE, // Logging level, available logging levels are: ULTRA_VERBOSE, VERBOSE, NOTICE, WARNING, ERROR, FATAL_ERROR. Can be provided as last parameter to the logging function.
'rollbar_token' => 'f9fff6689aea4905b58eec73f66c791d'
],
'max_tries' => [
'query' => 5, // How many times should I try to call a method or send an object before throwing an exception
@ -379,7 +380,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
public function setup_logger()
{
\Rollbar\Rollbar::init(['environment' => 'production', 'root' => __DIR__, 'access_token' => '31979a2053e045548573d29232dde9c5'], false, false);
\Rollbar\Rollbar::init(['environment' => 'production', 'root' => __DIR__, 'access_token' => isset($this->settings['logger']['rollbar_token']) ? $this->settings['logger']['rollbar_token'] : 'f9fff6689aea4905b58eec73f66c791d'], false, false);
\danog\MadelineProto\Logger::constructor($this->settings['logger']['logger'], $this->settings['logger']['logger_param'], isset($this->authorization['user']) ? (isset($this->authorization['user']['username']) ? $this->authorization['user']['username'] : $this->authorization['user']['id']) : '', isset($this->settings['logger']['logger_level']) ? $this->settings['logger']['logger_level'] : Logger::VERBOSE);
}
@ -529,7 +530,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
public function getV()
{
return 23;
return 24;
}
public function get_self()

View File

@ -272,9 +272,8 @@ trait Files
try {
$res = $cdn ? $this->method_call('upload.getCdnFile', ['file_token' => $info['file_token'], 'offset' => $offset, 'limit' => $part_size], ['heavy' => true, 'datacenter' => $datacenter]) : $this->method_call('upload.getFile', ['location' => $info['InputFileLocation'], 'offset' => $offset, 'limit' => $part_size], ['heavy' => true, 'datacenter' => $datacenter]);
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->getMessage() === 'OFFSET_INVALID') {
\Rollbar\Rollbar::log($info);
\Rollbar\Rollbar::log($offset);
if ($e->rpc === 'OFFSET_INVALID') {
\Rollbar\Rollbar::log(\Rollbar\Payload\Level::error(), $e->rpc, ['info' => $info, 'offset' => $offset]);
break;
} else {
throw $e;

View File

@ -54,6 +54,7 @@ class RPCErrorException extends \Exception
if (in_array($this->rpc, ['CHANNEL_PRIVATE'])) {
return;
}
if (strpos($this->rpc, 'FLOOD_WAIT_') !== false) return;
$additional = [];
foreach (debug_backtrace() as $level) {
if (isset($level['function']) && $level['function'] === 'method_call') {
@ -61,6 +62,6 @@ class RPCErrorException extends \Exception
break;
}
}
\Rollbar\Rollbar::log($this, $additional, 'error');
\Rollbar\Rollbar::log(\Rollbar\Payload\Level::error(), $this, $additional);
}
}