Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit 9db2982

Browse files
committed
wip
1 parent 12ab7e8 commit 9db2982

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace RikkaTech\SwooleHttp;
3+
4+
class AbstractController
5+
{
6+
public $request;
7+
public $response;
8+
public function __construct($request,$response)
9+
{
10+
$this->request = $request;
11+
$this->response = $response;
12+
}
13+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Logger.php
4+
*
5+
* @project swoole-httpserver
6+
* @author lixworth <lixworth@outlook.com>
7+
* @copyright swoole-httpserver
8+
* @create 2021/8/31 5:54
9+
*/
10+
namespace RikkaTech\SwooleHttp;
11+
12+
use RikkaTech\SwooleHttp\Singleton;
13+
14+
class Logger extends Singleton
15+
{
16+
private $format = "";
17+
18+
public static function template($from, $type, $message): string
19+
{
20+
return "[" . date("Y/H/D h:m:s") . "][" . $type . "][" . $from . "] " . $message . "\n";
21+
}
22+
23+
/**
24+
* @param $message
25+
* @param string $from
26+
* @return string
27+
*/
28+
public function info($message, string $from = 'Server'): void
29+
{
30+
fwrite(STDOUT, self::template($from, "INFO", $message));
31+
}
32+
33+
/**
34+
* @param $message
35+
* @param string $from
36+
* @return string
37+
*/
38+
public function success($message, string $from = 'Server'): void
39+
{
40+
fwrite(STDOUT, self::template($from, "SUCCESS", $message));
41+
}
42+
43+
/**
44+
* @param $message
45+
* @param string $from
46+
* @return string
47+
*/
48+
public function error($message, string $from = 'Server'): void
49+
{
50+
fwrite(STDOUT, self::template($from, "ERROR", $message));
51+
}
52+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @copyright swoole-httpserver
99
* @create 2021/8/31 5:52
1010
*/
11-
class HomeController extends Controller
11+
class HomeAbstractController extends AbstractController
1212
{
1313
public function index()
1414
{

0 commit comments

Comments
 (0)