-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConsoleLog.php
48 lines (40 loc) · 1.2 KB
/
ConsoleLog.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
<?php
declare(strict_types=1);
/**
*
* @author xiaoguo0426
* @contact [email protected]
* @license MIT
*/
namespace App\Util;
use Hyperf\Contract\StdoutLoggerInterface;
use Stringable;
use function Hyperf\Support\env;
/**
* Class ConsoleLog.
*
* @method void emergency(string|Stringable $message, array $context = [])
* @method void alert(string|Stringable $message, array $context = [])
* @method void critical(string|Stringable $message, array $context = [])
* @method void error(string|Stringable $message, array $context = [])
* @method void warning(string|Stringable $message, array $context = [])
* @method void notice(string|Stringable $message, array $context = [])
* @method void info(string|Stringable $message, array $context = [])
* @method void debug(string|Stringable $message, array $context = [])
*/
class ConsoleLog
{
protected StdoutLoggerInterface $logger;
public function __construct(StdoutLoggerInterface $logger)
{
$this->logger = $logger;
}
public function __call($name, $arguments)
{
return env('DEBUG') !== true ? $this->logger->{$name}(...$arguments) : null;
}
public function newLine(): void
{
echo "\r\n";
}
}