1 | <?php |
||||
2 | |||||
3 | use yii\log\Logger; |
||||
4 | |||||
5 | return [ |
||||
6 | 'timeZone' => env('APP_TIME_ZONE'), |
||||
7 | 'language' => env('APP_LANGUAGE'), |
||||
8 | 'name' => env('APP_NAME'), |
||||
9 | 'bootstrap' => ['log', 'ideHelper', \app\core\EventBootstrap::class], |
||||
10 | 'components' => [ |
||||
11 | 'ideHelper' => [ |
||||
12 | 'class' => 'Mis\IdeHelper\IdeHelper', |
||||
13 | 'configFiles' => [ |
||||
14 | 'config/web.php', |
||||
15 | 'config/common.php', |
||||
16 | 'config/console.php', |
||||
17 | ], |
||||
18 | ], |
||||
19 | 'telegram' => [ |
||||
20 | 'class' => 'aki\telegram\Telegram', |
||||
21 | 'botToken' => env('TELEGRAM_TOKEN'), |
||||
22 | ], |
||||
23 | 'requestId' => [ |
||||
24 | 'class' => \yiier\helpers\RequestId::class, |
||||
25 | ], |
||||
26 | 'cache' => [ |
||||
27 | 'class' => 'yii\caching\FileCache', |
||||
28 | ], |
||||
29 | 'formatter' => [ |
||||
30 | 'dateFormat' => 'yyyy-MM-dd', |
||||
31 | 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss', |
||||
32 | 'decimalSeparator' => ',', |
||||
33 | 'thousandSeparator' => ' ', |
||||
34 | 'currencyCode' => 'CNY', |
||||
35 | ], |
||||
36 | 'db' => [ |
||||
37 | 'class' => 'yii\db\Connection', |
||||
38 | 'dsn' => 'mysql:host=' . env('MYSQL_HOST') |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
39 | . ';port=' . env('MYSQL_PORT') |
||||
0 ignored issues
–
show
Are you sure
env('MYSQL_PORT') of type false|string can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | . ';dbname=' . env('MYSQL_DATABASE'), |
||||
0 ignored issues
–
show
Are you sure
env('MYSQL_DATABASE') of type false|string can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
41 | 'username' => env('MYSQL_USERNAME'), |
||||
42 | 'password' => env('MYSQL_PASSWORD'), |
||||
43 | 'charset' => 'utf8mb4', |
||||
44 | 'enableSchemaCache' => YII_ENV_PROD, |
||||
45 | 'schemaCacheDuration' => 60, |
||||
46 | 'schemaCache' => 'cache', |
||||
47 | ], |
||||
48 | 'i18n' => [ |
||||
49 | 'translations' => [ |
||||
50 | 'app*' => [ |
||||
51 | 'class' => 'yii\i18n\PhpMessageSource', |
||||
52 | 'basePath' => '@app/core/messages', |
||||
53 | 'fileMap' => [ |
||||
54 | 'app' => 'app.php', |
||||
55 | 'app/error' => 'exception.php', |
||||
56 | ], |
||||
57 | ], |
||||
58 | ], |
||||
59 | ], |
||||
60 | 'log' => [ |
||||
61 | 'traceLevel' => YII_DEBUG ? 3 : 0, |
||||
62 | 'targets' => [ |
||||
63 | [ |
||||
64 | 'class' => yiier\graylog\Target::class, |
||||
65 | // 日志等级 |
||||
66 | 'levels' => Logger::LEVEL_ERROR | Logger::LEVEL_WARNING, |
||||
67 | 'logVars' => ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION'], |
||||
68 | 'categories' => [ |
||||
69 | 'yii\db\*', |
||||
70 | 'yii\web\HttpException:*', |
||||
71 | 'application', |
||||
72 | ], |
||||
73 | 'except' => [ |
||||
74 | 'yii\web\HttpException:404', |
||||
75 | ], |
||||
76 | 'transport' => [ |
||||
77 | 'class' => yiier\graylog\transport\UdpTransport::class, |
||||
78 | 'host' => getenv('GRAYLOG_HOST'), |
||||
79 | 'chunkSize' => 4321, |
||||
80 | ], |
||||
81 | 'additionalFields' => [ |
||||
82 | 'request_id' => function ($yii) { |
||||
0 ignored issues
–
show
The parameter
$yii is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
83 | return Yii::$app->requestId->id; |
||||
84 | }, |
||||
85 | 'user_ip' => function ($yii) { |
||||
86 | return ($yii instanceof \yii\console\Application) ? '' : $yii->request->userIP; |
||||
87 | }, |
||||
88 | 'tag' => getenv('GRAYLOG_TAG') |
||||
89 | ], |
||||
90 | ], |
||||
91 | [ |
||||
92 | 'class' => yiier\graylog\Target::class, |
||||
93 | 'levels' => Logger::LEVEL_ERROR | Logger::LEVEL_WARNING | Logger::LEVEL_INFO, |
||||
94 | 'logVars' => ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION'], |
||||
95 | 'categories' => [ |
||||
96 | 'graylog' |
||||
97 | ], |
||||
98 | 'except' => [ |
||||
99 | 'yii\web\HttpException:404', |
||||
100 | ], |
||||
101 | 'transport' => [ |
||||
102 | 'class' => yiier\graylog\transport\UdpTransport::class, |
||||
103 | 'host' => getenv('GRAYLOG_HOST'), |
||||
104 | 'chunkSize' => 4321, |
||||
105 | ], |
||||
106 | 'additionalFields' => [ |
||||
107 | 'request_id' => function ($yii) { |
||||
0 ignored issues
–
show
The parameter
$yii is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
108 | return Yii::$app->requestId->id; |
||||
109 | }, |
||||
110 | 'user_ip' => function ($yii) { |
||||
111 | return ($yii instanceof \yii\console\Application) ? '' : $yii->request->userIP; |
||||
112 | }, |
||||
113 | 'tag' => getenv('GRAYLOG_TAG') |
||||
114 | ], |
||||
115 | ], |
||||
116 | /** |
||||
117 | * 错误级别日志:当某些需要立马解决的致命问题发生的时候,调用此方法记录相关信息。 |
||||
118 | * 使用方法:Yii::error() |
||||
119 | */ |
||||
120 | [ |
||||
121 | 'class' => 'yiier\helpers\FileTarget', |
||||
122 | // 日志等级 |
||||
123 | 'levels' => ['error'], |
||||
124 | 'except' => [ |
||||
125 | 'yii\web\HttpException:404', |
||||
126 | ], |
||||
127 | // 被收集记录的额外数据 |
||||
128 | 'logVars' => ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION'], |
||||
129 | // 指定日志保存的文件名 |
||||
130 | 'logFile' => '@app/runtime/logs/error/app.log', |
||||
131 | // 是否开启日志 (@app/runtime/logs/error/20151223_app.log) |
||||
132 | 'enableDatePrefix' => true, |
||||
133 | ], |
||||
134 | /** |
||||
135 | * 警告级别日志:当某些期望之外的事情发生的时候,使用该方法。 |
||||
136 | * 使用方法:Yii::warning() |
||||
137 | */ |
||||
138 | [ |
||||
139 | 'class' => 'yiier\helpers\FileTarget', |
||||
140 | // 日志等级 |
||||
141 | 'levels' => ['warning'], |
||||
142 | // 被收集记录的额外数据 |
||||
143 | 'logVars' => ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION'], |
||||
144 | // 指定日志保存的文件名 |
||||
145 | 'logFile' => '@app/runtime/logs/warning/app.log', |
||||
146 | // 是否开启日志 (@app/runtime/logs/warning/20151223_app.log) |
||||
147 | 'enableDatePrefix' => true, |
||||
148 | ], |
||||
149 | [ |
||||
150 | 'class' => 'yiier\helpers\FileTarget', |
||||
151 | 'levels' => ['info'], |
||||
152 | 'categories' => ['request'], |
||||
153 | 'logVars' => [], |
||||
154 | 'maxFileSize' => 1024, |
||||
155 | 'logFile' => '@app/runtime/logs/request/app.log', |
||||
156 | 'enableDatePrefix' => true |
||||
157 | ], |
||||
158 | [ |
||||
159 | 'class' => 'yiier\helpers\FileTarget', |
||||
160 | 'levels' => ['warning'], |
||||
161 | 'categories' => ['debug'], |
||||
162 | 'logVars' => [], |
||||
163 | 'maxFileSize' => 1024, |
||||
164 | 'logFile' => '@app/runtime/logs/debug/app.log', |
||||
165 | 'enableDatePrefix' => true |
||||
166 | ], |
||||
167 | ], |
||||
168 | ], |
||||
169 | ], |
||||
170 | ]; |
||||
171 |