Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
7ef2101c
Commit
7ef2101c
authored
Jun 08, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
试戴日志优化
parent
6728fa02
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
LogDb.php
addons/shopro/model/LogDb.php
+2
-2
TestLogDb.php
application/command/TestLogDb.php
+4
-4
common.php
application/common.php
+1
-1
No files found.
addons/shopro/model/LogDb.php
View file @
7ef2101c
...
@@ -42,11 +42,11 @@ class LogDb extends Model
...
@@ -42,11 +42,11 @@ class LogDb extends Model
$model
=
new
self
();
$model
=
new
self
();
$insertData
=
[
$insertData
=
[
'user_id'
=>
$data
[
'user_id'
]
??
0
,
'user_id'
=>
$data
[
'user_id'
]
??
0
,
'user_name'
=>
$data
[
'user_name'
]
??
''
,
//
'user_name' => $data['user_name'] ?? '',
'log_type'
=>
$data
[
'log_type'
]
??
'info'
,
'log_type'
=>
$data
[
'log_type'
]
??
'info'
,
'log_category'
=>
$data
[
'log_category'
]
??
'system'
,
'log_category'
=>
$data
[
'log_category'
]
??
'system'
,
'log_content'
=>
$data
[
'log_content'
]
??
''
,
'log_content'
=>
$data
[
'log_content'
]
??
''
,
'ip'
=>
$data
[
'ip'
]
??
request
()
->
ip
(),
//
'ip' => $data['ip'] ?? request()->ip(),
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
];
];
...
...
application/command/TestLogDb.php
View file @
7ef2101c
...
@@ -21,15 +21,15 @@ class TestLogDb extends Command
...
@@ -21,15 +21,15 @@ class TestLogDb extends Command
// 测试1:写入测试日志
// 测试1:写入测试日志
$output
->
writeln
(
'测试1:写入测试日志'
);
$output
->
writeln
(
'测试1:写入测试日志'
);
custom_log
(
'这是一条测试日志'
,
'test'
,
'info'
);
custom_log
(
'这是一条测试日志'
,
888
,
'test'
,
'info'
);
$output
->
writeln
(
'✓ 日志写入成功'
);
$output
->
writeln
(
'✓ 日志写入成功'
);
$output
->
writeln
(
''
);
$output
->
writeln
(
''
);
// 测试2:写入不同级别的日志
// 测试2:写入不同级别的日志
$output
->
writeln
(
'测试2:写入不同级别的日志'
);
$output
->
writeln
(
'测试2:写入不同级别的日志'
);
custom_log
(
'这是一条错误日志'
,
'test'
,
'error'
);
custom_log
(
'这是一条错误日志'
,
888
,
'test'
,
'error'
);
custom_log
(
'这是一条调试日志'
,
'test'
,
'debug'
);
custom_log
(
'这是一条调试日志'
,
888
,
'test'
,
'debug'
);
custom_log
(
'这是一条警告日志'
,
'test'
,
'warning'
);
custom_log
(
'这是一条警告日志'
,
888
,
'test'
,
'warning'
);
$output
->
writeln
(
'✓ 不同级别日志写入成功'
);
$output
->
writeln
(
'✓ 不同级别日志写入成功'
);
$output
->
writeln
(
''
);
$output
->
writeln
(
''
);
...
...
application/common.php
View file @
7ef2101c
...
@@ -527,7 +527,7 @@ if (!function_exists('custom_log')) {
...
@@ -527,7 +527,7 @@ if (!function_exists('custom_log')) {
\think\Log
::
record
(
$content
,
$level
);
\think\Log
::
record
(
$content
,
$level
);
// 同时记录到数据库日志表
// 同时记录到数据库日志表
custom_log_db
(
$content
,
$name
,
$level
);
custom_log_db
(
$content
,
$
user_id
,
$
name
,
$level
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment