作者 竞泽

style:format

... ... @@ -4,7 +4,7 @@ use Lackoxygen\ExceptionPush\Agents\{Ding, Wx};
return [
'agents' => [
Wx::class => [
Wx::class => [
'key' => '', 'enable' => false
], Ding::class => [
'token' => '', 'secret' => '', 'enable' => false
... ...
... ... @@ -22,7 +22,7 @@ class Ding implements AgentInterface
$talk->setTextMessage(join("\n", $content))->send();
}
public function dsiabled(): bool
public function disabled(): bool
{
return !$this->enable;
}
... ...
... ... @@ -23,11 +23,11 @@ class Wx implements AgentInterface
$client = Client::new('https://qyapi.weixin.qq.com');
$client->post('cgi-bin/webhook/send', [
RequestOptions::HEADERS => [
RequestOptions::HEADERS => [
'content-type' => 'application/json'
], RequestOptions::QUERY => [
'key' => $this->key,
], RequestOptions::JSON => [
], RequestOptions::JSON => [
'msgtype' => 'text', 'text' => [
'content' => join("\n", $content)
]
... ... @@ -35,7 +35,7 @@ class Wx implements AgentInterface
]);
}
public function dsiabled(): bool
public function disabled(): bool
{
return !$this->enable;
}
... ...
... ... @@ -37,7 +37,7 @@ class Context
}
/**
* @param string $exception
* @param string $exception
*/
public function setException(string $exception): void
{
... ... @@ -53,7 +53,7 @@ class Context
}
/**
* @param string $message
* @param string $message
*/
public function setMessage(string $message): void
{
... ... @@ -69,7 +69,7 @@ class Context
}
/**
* @param string $code
* @param string $code
*/
public function setCode(string $code): void
{
... ... @@ -85,7 +85,7 @@ class Context
}
/**
* @param string $line
* @param string $line
*/
public function setLine(string $line): void
{
... ... @@ -101,7 +101,7 @@ class Context
}
/**
* @param string $file
* @param string $file
*/
public function setFile(string $file): void
{
... ... @@ -117,7 +117,7 @@ class Context
}
/**
* @param array $trace
* @param array $trace
*/
public function setTrace(array $trace): void
{
... ... @@ -133,7 +133,7 @@ class Context
}
/**
* @param string $path
* @param string $path
*/
public function setPath(string $path): void
{
... ... @@ -149,7 +149,7 @@ class Context
}
/**
* @param string $method
* @param string $method
*/
public function setMethod(string $method): void
{
... ... @@ -165,7 +165,7 @@ class Context
}
/**
* @param AgentInterface $agent
* @param AgentInterface $agent
*/
public function pushAgent(AgentInterface $agent): void
{
... ... @@ -173,7 +173,7 @@ class Context
}
/**
* @param string $ip
* @param string $ip
*/
public function setIp(string $ip): void
{
... ... @@ -189,7 +189,7 @@ class Context
}
/**
* @param array $input
* @param array $input
*/
public function setInput(array $input): void
{
... ... @@ -205,7 +205,7 @@ class Context
}
/**
* @param array $extras
* @param array $extras
*/
public function setExtras(array $extras): void
{
... ... @@ -227,8 +227,8 @@ class Context
{
return [
'exception' => $this->exception, 'message' => $this->message, 'ip' => $this->ip, 'code' => $this->code,
'line' => $this->line, 'file' => $this->file, 'trace' => $this->trace, 'path' => $this->path,
'method' => $this->method, 'agents' => $this->agents, 'input' => $this->input
'line' => $this->line, 'file' => $this->file, 'trace' => $this->trace, 'path' => $this->path,
'method' => $this->method, 'agents' => $this->agents, 'input' => $this->input
];
}
... ...
... ... @@ -16,7 +16,7 @@ class Client
public function __construct(string $baseUri)
{
$this->engine = new \GuzzleHttp\Client([
'base_uri' => $baseUri, RequestOptions::TIMEOUT => ExceptionPush::config('client.timeout', 30),
'base_uri' => $baseUri, RequestOptions::TIMEOUT => ExceptionPush::config('client.timeout', 30),
RequestOptions::VERIFY => false
]);
}
... ...
... ... @@ -6,5 +6,5 @@ interface AgentInterface
{
public function report(array $content);
public function dsiabled(): bool;
public function disabled(): bool;
}
... ...
... ... @@ -8,7 +8,7 @@ use Throwable;
class Handler extends BaseHandler
{
/**
* @param Throwable $e
* @param Throwable $e
*
* @return void
* @throws Throwable
... ... @@ -29,7 +29,7 @@ class Handler extends BaseHandler
}
/**
* @param Throwable $e
* @param Throwable $e
*
* @return void
*/
... ...
... ... @@ -31,7 +31,7 @@ class ExceptionPush
*/
public static function getAgents($options = null): array
{
$agentOpts = $options ? : (array) static::config('agents');
$agentOpts = $options ?: (array)static::config('agents');
$agents = [];
... ... @@ -94,7 +94,7 @@ class ExceptionPush
}
/**
* @param array $body
* @param array $body
*
* @return void
*/
... ...
... ... @@ -16,7 +16,7 @@ class ExceptionPushProvider extends ServiceProvider
public function boot()
{
if ($this->app->runningInConsole()) {
$configPath = __DIR__.'/../publish/exception.push.php';
$configPath = __DIR__ . '/../publish/exception.push.php';
$this->publishes([
$configPath => config_path('exception.push.php')
], 'lackoxygen-exception-push');
... ...
... ... @@ -15,12 +15,12 @@ class Formatter implements CallbackInterface
{
return function (Context $context) {
return [
'时间:'.Carbon::now()->toDateTimeString(), '环境:'.config('app.env'), '项目:'.config('app.name'),
'参数:'.json_encode($context->getInput()), 'runtime:'.php_sapi_name(), '地址:'.$context->getPath(),
'请求方法:'.$context->getMethod(), 'IP:'.$context->getIp(),
'异常:'.sprintf('%s(%s)(code:%d):at %s:%d', $context->getException(), $context->getMessage(),
'时间:' . Carbon::now()->toDateTimeString(), '环境:' . config('app.env'), '项目:' . config('app.name'),
'参数:' . json_encode($context->getInput()), 'runtime:' . php_sapi_name(), '地址:' . $context->getPath(),
'请求方法:' . $context->getMethod(), 'IP:' . $context->getIp(),
'异常:' . sprintf('%s(%s)(code:%d):at %s:%d', $context->getException(), $context->getMessage(),
$context->getCode(), $context->getFile(), $context->getLine()),
'trace:'.implode(PHP_EOL, $context->getTrace()),
'trace:' . implode(PHP_EOL, $context->getTrace()),
];
};
}
... ...
... ... @@ -33,17 +33,18 @@ class MonologHandler extends AbstractSyslogHandler
protected array $channels = [];
/**
* @param array $channels
* @param array $channels
* @param $facility
* @param $level
* @param bool $bubble
* @param bool $bubble
*/
public function __construct(
array $channels,
$facility = LOG_USER,
$level = Logger::DEBUG,
bool $bubble = true
) {
$facility = LOG_USER,
$level = Logger::DEBUG,
bool $bubble = true
)
{
parent::__construct($facility, $level, $bubble);
$this->dispatcher = Dispatcher::callback();
... ... @@ -52,7 +53,7 @@ class MonologHandler extends AbstractSyslogHandler
}
/**
* @param array $record
* @param array $record
*
* @return void
*/
... ...
... ... @@ -32,7 +32,7 @@ class Parser
}
/**
* @param string $line
* @param string $line
*
* @return string
*/
... ... @@ -42,7 +42,7 @@ class Parser
}
/**
* @param \Throwable $e
* @param \Throwable $e
*
* @return void
*/
... ... @@ -53,7 +53,7 @@ class Parser
$this->context->setException(get_class($this->throw));
$this->context->setMethod($this->request->getMethod());
$this->context->setPath($this->request->path());
$this->context->setCode((string) $this->throw->getCode());
$this->context->setCode((string)$this->throw->getCode());
$this->context->setFile($this->realpath($this->throw->getFile()));
$this->context->setLine($this->throw->getLine());
$this->context->setMessage($this->throw->getMessage());
... ...