Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
without authentication
meibuyu-micro
Commits
efd84316
Commit
efd84316
authored
Jan 13, 2023
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化日志记录
parent
21452074
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
LogTraceHandler.php
src/Handler/LogTrace/LogTraceHandler.php
+1
-1
RedisQueueBatchHandler.php
src/Handler/RedisQueueBatchHandler.php
+4
-4
No files found.
src/Handler/LogTrace/LogTraceHandler.php
View file @
efd84316
...
@@ -106,7 +106,7 @@ class LogTraceHandler
...
@@ -106,7 +106,7 @@ class LogTraceHandler
}
else
if
(
is_string
(
$track
)
||
is_numeric
(
$track
))
{
}
else
if
(
is_string
(
$track
)
||
is_numeric
(
$track
))
{
$logInfo
=
$track
;
$logInfo
=
$track
;
}
else
{
}
else
{
$logInfo
=
print_r
(
$track
,
true
);
$logInfo
=
json_encode
(
$track
,
JSON_PRETTY_PRINT
);
;
//
print_r($track, true);
}
}
$logInfo
.=
"
\n\n
"
;
$logInfo
.=
"
\n\n
"
;
...
...
src/Handler/RedisQueueBatchHandler.php
View file @
efd84316
...
@@ -72,8 +72,6 @@ abstract class RedisQueueBatchHandler
...
@@ -72,8 +72,6 @@ abstract class RedisQueueBatchHandler
//每次从列表取100
//每次从列表取100
$arr
=
$this
->
redis
->
lRange
(
$this
->
queue_name
,
0
,
self
::
BATCH_DEAL_NUM
-
1
);
$arr
=
$this
->
redis
->
lRange
(
$this
->
queue_name
,
0
,
self
::
BATCH_DEAL_NUM
-
1
);
//取完 从队列删掉
$this
->
redis
->
lTrim
(
$this
->
queue_name
,
count
(
$arr
),
-
1
);
//数据格式化
//数据格式化
$formatArr
=
array_map
(
function
(
$item
){
$formatArr
=
array_map
(
function
(
$item
){
return
json_decode
(
$item
,
true
);
return
json_decode
(
$item
,
true
);
...
@@ -81,15 +79,17 @@ abstract class RedisQueueBatchHandler
...
@@ -81,15 +79,17 @@ abstract class RedisQueueBatchHandler
try
{
try
{
//具体批处理逻辑
//具体批处理逻辑
$this
->
batchDeal
(
$formatArr
);
$this
->
batchDeal
(
$formatArr
);
//取完 从队列删掉
$this
->
redis
->
lTrim
(
$this
->
queue_name
,
count
(
$arr
),
-
1
);
}
catch
(
\Throwable
$exception
){
}
catch
(
\Throwable
$exception
){
//错误码为100 重新推到队列
//错误码为100 重新推到队列
if
(
$exception
->
getCode
()
==
self
::
ERROR_RETRY_CODE
){
if
(
$exception
->
getCode
()
==
self
::
ERROR_RETRY_CODE
){
if
(
$this
->
retry
<
self
::
MAX_RETRY_TIMES
){
//重试次数不超过3次
if
(
$this
->
retry
<
self
::
MAX_RETRY_TIMES
){
//重试次数不超过3次
$this
->
backToQueue
(
$arr
);
//
$this->backToQueue($arr);
$this
->
retry
++
;
$this
->
retry
++
;
}
else
{
}
else
{
$this
->
redis
->
lTrim
(
$this
->
queue_name
,
count
(
$arr
),
-
1
);
$this
->
retry
=
0
;
//重置当前次数
$this
->
retry
=
0
;
//重置当前次数
$this
->
errorWriteToFile
(
$formatArr
,
$exception
);
$this
->
errorWriteToFile
(
$formatArr
,
$exception
);
}
}
...
...
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