Skip to content

Commit 6e4941d

Browse files
committed
add: 执行时间记录和统计工具 running-time
```shell php artisan running-time ``` 参考资料: 1. [https://github.com/y-ui/laravel-running-time](https://github.com/y-ui/laravel-running-time) 2. [https://learnku.com/laravel/t/25396](https://learnku.com/laravel/t/25396)
1 parent 59ff796 commit 6e4941d

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

laravel/app/Http/Kernel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class Kernel extends HttpKernel
3636
// 跨域访问中间件
3737
// \App\Http\Middleware\Cors::class,
3838
\Barryvdh\Cors\HandleCors::class,
39+
40+
// 执行时间记录和统计工具
41+
\RunningTime\Middleware\RunningTimeMiddleware::class,
3942
];
4043

4144
/**

laravel/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"predis/predis": "^1.1",
2424
"tymon/jwt-auth": "1.*@rc",
2525
"vinkla/hashids": "3.3.0",
26+
"y-ui/laravel-running-time": "^1.1",
2627
"zhuzhichao/ip-location-zh": "^2.4"
2728
},
2829
"require-dev": {

laravel/composer.lock

Lines changed: 47 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

laravel/config/app.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@
196196
Laravel\Scout\ScoutServiceProvider::class,
197197
Baijunyao\LaravelScoutElasticsearch\ElasticsearchServiceProvider::class,
198198

199+
// 执行时间记录和统计工具
200+
\RunningTime\RunningTimeServiceProvider::class,
201+
199202
],
200203

201204
/*

laravel/config/runningtime.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
4+
return [
5+
6+
/*
7+
|---------------------------------------------------------------------------
8+
| Write Mode
9+
|---------------------------------------------------------------------------
10+
|
11+
| The mode of write file, default write file immediately
12+
| If the qps of your app is very large, please select delay mode
13+
| default: real_time
14+
|
15+
| options: delay
16+
*/
17+
'mode' => 'real_time',
18+
19+
/*
20+
|---------------------------------------------------------------------------
21+
| Delayed Write
22+
|---------------------------------------------------------------------------
23+
|
24+
| When mode select daley
25+
| If the next request is more than maximum_time seconds from the first request or the cumulative number of logs exceeds maximum_log,
26+
| all logs in this period are written in batches.
27+
| And this need redis
28+
*/
29+
'delay' => [
30+
'time' => 60, // This is not strictly written after time seconds
31+
'log' => 60,
32+
],
33+
34+
'path' => storage_path('logs/runningtime/'),
35+
36+
'memory_limit' => '512M', // PHP memory_limit
37+
38+
];

0 commit comments

Comments
 (0)