-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
639 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# [Command collector](./../../../../src/Collector/Console/CommandCollector.php) | ||
|
||
`CommandCollector` collects all data about an executed console command. | ||
|
||
It uses the following events to collect data: | ||
- [`\Symfony\Component\Console\Event\ConsoleCommandEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php) | ||
- [`\Symfony\Component\Console\Event\ConsoleTerminateEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php) | ||
- [`\Symfony\Component\Console\Event\ConsoleErrorEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php) | ||
|
||
## Collected data | ||
|
||
### Common | ||
|
||
Example: | ||
|
||
`console/commands.php` | ||
|
||
```php | ||
return [ | ||
'app:hello' => \App\Command\HelloCommand::class, | ||
]; | ||
``` | ||
|
||
`App\Command\HelloCommand` | ||
|
||
```php | ||
final class HelloCommand extends Command | ||
{ | ||
protected static $defaultName = 'app:hello'; | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$output->writeln('Hello world!'); | ||
return 0; | ||
} | ||
} | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
{ | ||
"Symfony\\Component\\Console\\Event\\ConsoleCommandEvent": { | ||
"name": "app:hello", | ||
"command": "object@App\\Command\\HelloCommand#8454", | ||
"input": "'app:hello'", | ||
"output": "", | ||
"arguments": { | ||
"command": "object@Symfony\\Component\\Console\\Input\\InputArgument#8532" | ||
}, | ||
"options": { | ||
"help": "object@Symfony\\Component\\Console\\Input\\InputOption#8523", | ||
"quiet": "object@Symfony\\Component\\Console\\Input\\InputOption#8520", | ||
"verbose": "object@Symfony\\Component\\Console\\Input\\InputOption#8524", | ||
"version": "object@Symfony\\Component\\Console\\Input\\InputOption#8522", | ||
"ansi": "object@Symfony\\Component\\Console\\Input\\InputOption#8521", | ||
"no-interaction": "object@Symfony\\Component\\Console\\Input\\InputOption#8517", | ||
"config": "object@Symfony\\Component\\Console\\Input\\InputOption#40" | ||
} | ||
}, | ||
"Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent": { | ||
"name": "app:hello", | ||
"command": "object@App\\Command\\HelloCommand#8454", | ||
"input": "'app:hello'", | ||
"output": "Hello world!\n", | ||
"exitCode": 0 | ||
} | ||
} | ||
``` | ||
|
||
### Summary | ||
|
||
```json | ||
{ | ||
"command": { | ||
"name": "app:hello", | ||
"class": "App\\Command\\HelloCommand", | ||
"input": "'app:hello'", | ||
"exitCode": 0 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# [ConsoleAppInfo collector](./../../../../src/Collector/Console/ConsoleAppInfoCollector.php) | ||
|
||
`ConsoleAppInfoCollector` collects information about the application. | ||
|
||
It uses the following events to collect data: | ||
- [`\Yiisoft\Yii\Console\Event\ApplicationStartup`](https://github.com/yiisoft/yii-console/blob/master/src/Event/ApplicationStartup.php) | ||
- [`\Yiisoft\Yii\Console\Event\ApplicationShutdown`](https://github.com/yiisoft/yii-console/blob/master/src/Event/ApplicationShutdown.php) | ||
- [`\Symfony\Component\Console\Event\ConsoleCommandEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleCommandEvent.php) | ||
- [`\Symfony\Component\Console\Event\ConsoleTerminateEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php) | ||
- [`\Symfony\Component\Console\Event\ConsoleErrorEvent`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Console/Event/ConsoleErrorEvent.php) | ||
|
||
## Collected data | ||
|
||
### Common | ||
|
||
Example: | ||
|
||
`console/commands.php` | ||
|
||
```php | ||
return [ | ||
'app:hello' => \App\Command\HelloCommand::class, | ||
]; | ||
``` | ||
|
||
`App\Command\HelloCommand` | ||
|
||
```php | ||
final class HelloCommand extends Command | ||
{ | ||
protected static $defaultName = 'app:hello'; | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$output->writeln('Hello world!'); | ||
return 0; | ||
} | ||
} | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
{ | ||
"applicationProcessingTime": 0.016509056091308594, | ||
"preloadTime": -0.014687061309814453, | ||
"applicationEmit": 0.0016329288482666016, | ||
"requestProcessingTime": 0.00018906593322753906, | ||
"memoryPeakUsage": 16445144, | ||
"memoryUsage": 16347512 | ||
} | ||
``` | ||
|
||
### Summary | ||
|
||
```json | ||
{ | ||
"console": { | ||
"php": { | ||
"version": "8.2.8" | ||
}, | ||
"request": { | ||
"startTime": 1704625438.335058, | ||
"processingTime": 0.00018906593322753906 | ||
}, | ||
"memory": { | ||
"peakUsage": 20338080 | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ Output: | |
|
||
```json | ||
{ | ||
"total": 1 | ||
"event": { | ||
"total": 1 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# [Exception collector](./../../../src/Collector/ExceptionCollector.php) | ||
|
||
`ExceptionCollector` collects all data about an exception that was not caught by the application. | ||
|
||
It uses [`\Yiisoft\ErrorHandler\Event\ApplicationError`](https://github.com/yiisoft/error-handler/blob/master/src/Event/ApplicationError.php) event to collect data. | ||
|
||
## Collected data | ||
|
||
### Common | ||
|
||
Example: | ||
|
||
```php | ||
final class SiteController | ||
{ | ||
public function __construct(private ViewRenderer $viewRenderer) | ||
{ | ||
$this->viewRenderer = $viewRenderer->withController($this); | ||
} | ||
|
||
public function index(LoggerInterface $logger): ResponseInterface | ||
{ | ||
throw new \Exception('Hello, world!'); | ||
return $this->viewRenderer->render('index'); | ||
} | ||
} | ||
|
||
``` | ||
|
||
Output: | ||
|
||
```json | ||
[ | ||
{ | ||
"class": "Exception", | ||
"message": "Hello, world!", | ||
"file": ".../demo\/blog\/src\/Controller\/SiteController.php", | ||
"line": 19, | ||
"code": 0, | ||
"trace": [ | ||
{ | ||
"function": "index", | ||
"class": "App\\Controller\\SiteController", | ||
"type": "->", | ||
"args": [ | ||
"object@HttpSoft\\Message\\ServerRequest#8094", | ||
"object@App\\Handler\\NotFoundHandler#8503" | ||
] | ||
}, | ||
// long long stack trace | ||
// ... | ||
{ | ||
"file": ".../demo\/blog\/vendor\/yiisoft\/yii-runner-http\/src\/HttpApplicationRunner.php", | ||
"line": 144, | ||
"function": "handle", | ||
"class": "Yiisoft\\Yii\\Http\\Application", | ||
"type": "->", | ||
"args": [ | ||
"object@HttpSoft\\Message\\ServerRequest#8354" | ||
] | ||
}, | ||
{ | ||
"file": ".../demo\/blog\/public\/index.php", | ||
"line": 40, | ||
"function": "run", | ||
"class": "Yiisoft\\Yii\\Runner\\Http\\HttpApplicationRunner", | ||
"type": "->", | ||
"args": [] | ||
} | ||
], | ||
"traceAsString": "..." // same long stack trace, but as a string | ||
} | ||
] | ||
``` | ||
|
||
### Summary | ||
|
||
```json | ||
{ | ||
"exception": { | ||
"class": "Exception", | ||
"message": "Hello, world!", | ||
"file": ".../demo\/blog\/src\/Controller\/SiteController.php", | ||
"line": 19, | ||
"code": 0 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,8 @@ Output: | |
|
||
```json | ||
{ | ||
"total": 2 | ||
"logger": { | ||
"total": 2 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ Output: | |
|
||
```json | ||
{ | ||
"total": 3 | ||
"var-dumper": { | ||
"total": 3 | ||
} | ||
} | ||
``` |
Oops, something went wrong.