Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
L
logtransfer
Project
Project
Details
Activity
Releases
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
谢宇轩
logtransfer
Commits
374164fd
Commit
374164fd
authored
Jan 07, 2022
by
谢宇轩
😅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改时区的bug
parent
2b7c019b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
format.go
entity/format.go
+9
-2
matedata.go
entity/matedata.go
+15
-4
No files found.
entity/format.go
View file @
374164fd
...
...
@@ -8,6 +8,10 @@ import (
"time"
)
const
(
Location
=
"Asia/Shanghai"
)
type
Formater
func
(
string
,
string
)
(
Matedata
,
error
)
// service错误日志的处理
...
...
@@ -23,7 +27,8 @@ func FormatServiceWfLog(sourceKey string, message string) (Matedata, error) {
mateItem
.
Topic
=
sourceKey
mateItem
.
Level
=
message
[
:
levelIndex
]
message
=
message
[
levelIndex
:
]
loc
,
_
:=
time
.
LoadLocation
(
"Local"
)
loc
,
_
:=
time
.
LoadLocation
(
Location
)
logTime
,
_
:=
time
.
ParseInLocation
(
": 06-01-02 15:04:05 "
,
message
[
:
strings
.
Index
(
message
,
"["
)],
loc
)
mateItem
.
create
=
logTime
keyword
:=
serviceWfLogKeyWord
...
...
@@ -65,7 +70,7 @@ func DefaultLog(sourceKey string, message string) (Matedata, error) {
return
result
,
nil
}
// Json 格式的错误日志处理
//
标志
Json 格式的错误日志处理
func
DefaultJsonLog
(
sourceKey
string
,
message
string
)
(
Matedata
,
error
)
{
vMateItem
:=
MatePool
.
Get
()
...
...
@@ -82,3 +87,5 @@ func DefaultJsonLog(sourceKey string, message string) (Matedata, error) {
MatePool
.
Put
(
vMateItem
)
return
result
,
nil
}
func
\ No newline at end of file
entity/matedata.go
View file @
374164fd
...
...
@@ -36,7 +36,7 @@ func (m *Matedata) reset() {
func
HandleMessage
(
m
*
Matedata
)
{
messages
<-
m
}
func
CloseMessageChan
()
{
close
(
messages
)
}
...
...
@@ -90,20 +90,31 @@ func MatedateSender(ctx context.Context) {
var
mateDatesItems
[]
*
Matedata
var
mu
sync
.
Mutex
autoTicker
:=
time
.
NewTicker
(
10
*
time
.
Second
)
for
{
select
{
case
m
:=
<-
messages
:
mu
.
Lock
()
mateDatesItems
=
append
(
mateDatesItems
,
m
)
currentItems
:=
mateDatesItems
mu
.
Unlock
()
if
len
(
currentItems
)
>
10
{
mateDatesItems
=
mateDatesItems
[
:
0
]
mu
.
Unlock
()
wp
.
Serve
(
currentItems
)
mu
.
Lock
()
}
else
{
mu
.
Unlock
()
}
case
<-
autoTicker
.
C
:
mu
.
Lock
()
currentItems
:=
mateDatesItems
if
len
(
currentItems
)
>
0
{
mateDatesItems
=
mateDatesItems
[
:
0
]
mu
.
Unlock
()
wp
.
Serve
(
currentItems
)
}
else
{
mu
.
Unlock
()
}
case
<-
ctx
.
Done
()
:
...
...
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