Skip to content

Commit cbf8777

Browse files
committed
modify: 代码优化
1 parent c57dbe7 commit cbf8777

2 files changed

Lines changed: 44 additions & 38 deletions

File tree

functions.php

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,56 +36,72 @@ function app(string $id)
3636
return kernel()->getContainer()->get($id);
3737
}
3838

39-
function emergency(string $message, array $context = [])
40-
{
41-
app('logger')->emergency($message, $context);
39+
if (!function_exists('emergency')) {
40+
function emergency(string $message, array $context = [])
41+
{
42+
app('logger')->emergency($message, $context);
43+
}
4244
}
4345

44-
function alert(string $message, array $context = [])
45-
{
46-
app('logger')->alert($message, $context);
46+
if (!function_exists('emergency')) {
47+
function alert(string $message, array $context = [])
48+
{
49+
app('logger')->alert($message, $context);
50+
}
4751
}
4852

49-
function critical(string $message, array $context = [])
50-
{
51-
app('logger')->critical($message, $context);
53+
if (!function_exists('emergency')) {
54+
function critical(string $message, array $context = [])
55+
{
56+
app('logger')->critical($message, $context);
57+
}
5258
}
5359

54-
function error(string $message, array $context = [])
55-
{
56-
app('logger')->error($message, $context);
60+
if (!function_exists('emergency')) {
61+
function error(string $message, array $context = [])
62+
{
63+
app('logger')->error($message, $context);
64+
}
5765
}
5866

59-
function warning(string $message, array $context = [])
60-
{
61-
app('logger')->warning($message, $context);
67+
if (!function_exists('emergency')) {
68+
function warning(string $message, array $context = [])
69+
{
70+
app('logger')->warning($message, $context);
71+
}
6272
}
6373

64-
function notice(string $message, array $context = [])
65-
{
66-
app('logger')->notice($message, $context);
74+
if (!function_exists('emergency')) {
75+
function notice(string $message, array $context = [])
76+
{
77+
app('logger')->notice($message, $context);
78+
}
6779
}
6880

69-
function info(string $message, array $context = [])
70-
{
71-
app('logger')->info($message, $context);
81+
if (!function_exists('emergency')) {
82+
function info(string $message, array $context = [])
83+
{
84+
app('logger')->info($message, $context);
85+
}
7286
}
7387

74-
function debug(string $message, array $context = [])
75-
{
76-
app('logger')->debug($message, $context);
88+
if (!function_exists('emergency')) {
89+
function debug(string $message, array $context = [])
90+
{
91+
app('logger')->debug($message, $context);
92+
}
7793
}
7894

79-
if (!function_exists('backtrace')) {
95+
if (!function_exists('backtracePoint')) {
8096
/**
8197
* 返回指定调用回溯位置信息
8298
*
8399
* @param int $depth 栈深度
84100
*/
85101
function backtracePoint(int $depth = 2): array
86102
{
87-
return array_pop(
88-
debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth)
89-
);
103+
$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth);
104+
105+
return array_pop($traces);
90106
}
91107
}

src/Kernel/Backtrace.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)