-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathLogHandle.php
76 lines (71 loc) · 1.94 KB
/
LogHandle.php
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/********************************************
* Easy PHP *
* *
* A lightweight PHP framework for studying *
* *
* TIERGB *
* <https://github.com/TIGERB> *
* *
********************************************/
namespace Framework\Handles;
use Framework\App;
use Framework\Handles\Handle;
use Framework\Exceptions\CoreHttpException;
use Easy\Log;
/**
* 框架日志处理
*
* Framework's log class
*
* @author TIERGB <https://github.com/TIGERB>
*/
class LogHandle implements Handle
{
/**
* log config
*
* @var string
*/
private $logConfig = '';
/**
* init the easy log
*
* @param App $app 框架实例
* @return void
*/
public function register(App $app)
{
new LogHandle();
}
/**
* 构造函数
*
* construct
*/
public function __construct()
{
/**
* 日志目录检查
*
* check log path env config
*/
$this->logConfig = env('log');
if (empty($this->logConfig)) {
throw new CoreHttpException(400, 'log config is not defined');
}
if (! isset($this->logConfig['path'])) {
throw new CoreHttpException(400, 'log path is not defined');
}
if (! isset($this->logConfig['name'])) {
throw new CoreHttpException(400, 'log name is not defined');
}
if (! isset($this->logConfig['size'])) {
throw new CoreHttpException(400, 'log size is not defined');
}
$instance = Log::getInstance();
$instance->logFileName = $this->logConfig['name'];
$instance->logPath = App::$app->rootPath . $this->logConfig['path'];
$instance->logFileSize = $this->logConfig['size'];
}
}