AppErrorLog.php
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace common\helpers;
use Yii;
use yii\base\Object;
/**
* 应用程序错误日志:
* 1) 写入app-xx/runtime/logs/app-日期.log
* 2) 写入system_log数据表
* 3) 发邮件给对应app-xx模块的负责人
* Class OrderLogHelper
* @package common\helpers
*/
class AppErrorLog extends Object
{
const CATEGORY_SYSTEM = 'system'; // 系统
const CATEGORY_APP_API = 'app_api'; // 小程序API
const CATEGORY_APP_DD = 'app_dd'; // 钉钉客户端
const CATEGORY_APP_HT = 'app_ht'; // 管理后台
const CATEGORY_APP_PAY = 'app_pay'; // 支付
const CATEGORY_APP_USER = 'app_user'; // 用户公众号
const CATEGORY_APP_WX = 'app_wx'; // 工程师公众号
const CATEGORY_CONSOLE = 'console'; // 控制台
const CATEGORY_DOMAIN = 'domain'; // 业务领域层
/**
* 获取支持的错误类别
* @return array
*/
public static function getSupportCategories()
{
$SUPPORT_CATEGORIES = [
'yii\base\*',
'yii\db\*',
self::CATEGORY_SYSTEM,
self::CATEGORY_APP_API,
self::CATEGORY_APP_DD,
self::CATEGORY_APP_HT,
self::CATEGORY_APP_PAY,
self::CATEGORY_APP_USER,
self::CATEGORY_APP_WX,
self::CATEGORY_CONSOLE,
self::CATEGORY_DOMAIN
];
return $SUPPORT_CATEGORIES;
}
public static function error($msg, $category = self::CATEGORY_SYSTEM)
{
Yii::error($msg, $category);
}
}