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
9a310ea9
Commit
9a310ea9
authored
Jan 13, 2022
by
谢宇轩
😅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新规划时区的配置
parent
dc02ba53
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
19 deletions
+14
-19
Dockerfile
Dockerfile
+2
-0
format.go
entity/format.go
+6
-10
alarm.go
plugin/alarm.go
+6
-9
No files found.
Dockerfile
View file @
9a310ea9
...
...
@@ -18,4 +18,6 @@ WORKDIR /app
COPY
--from=build /app /app
VOLUME
/app/log/
ENTRYPOINT
["/app/logtransfer"]
entity/format.go
View file @
9a310ea9
...
...
@@ -8,10 +8,6 @@ import (
"time"
)
const
(
Location
=
"Asia/Shanghai"
)
type
Formater
func
(
string
,
string
)
(
Matedata
,
error
)
// service错误日志的处理
...
...
@@ -28,11 +24,9 @@ func FormatServiceWfLog(sourceKey string, message string) (Matedata, error) {
mateItem
.
Level
=
message
[
:
levelIndex
]
message
=
message
[
levelIndex
:
]
loc
,
err
:=
time
.
LoadLocation
(
"UTC"
)
if
err
!=
nil
{
loc
=
time
.
FixedZone
(
"UTC"
,
0
)
}
logTime
,
_
:=
time
.
ParseInLocation
(
": 06-01-02 15:04:05 "
,
message
[
:
strings
.
Index
(
message
,
"["
)],
loc
)
// 给时间调回UTC+8
logTime
,
_
:=
time
.
ParseInLocation
(
": 06-01-02 15:04:05 "
,
message
[
:
strings
.
Index
(
message
,
"["
)],
time
.
FixedZone
(
"UTC"
,
8
*
3600
))
mateItem
.
create
=
logTime
keyword
:=
serviceWfLogKeyWord
for
_
,
word
:=
range
keyword
{
...
...
@@ -51,7 +45,9 @@ func FormatServiceWfLog(sourceKey string, message string) (Matedata, error) {
}
}
mateItem
.
Data
[
"timestamp"
]
=
mateItem
.
create
.
Format
(
"2006-01-02 15:04:05"
)
// 那这里获取UTC时间为8小时前
mateItem
.
Data
[
"timestamp"
]
=
mateItem
.
create
.
UTC
()
.
Format
(
"2006-01-02 15:04:05"
)
result
:=
*
mateItem
mateItem
.
reset
()
MatePool
.
Put
(
mateItem
)
...
...
plugin/alarm.go
View file @
9a310ea9
...
...
@@ -8,10 +8,6 @@ import (
"github.com/y7ut/logtransfer/entity"
)
const
(
Location
=
"Asia/Shanghai"
)
// 打印插件
type
Dump
Plugin
...
...
@@ -19,14 +15,15 @@ func (dump *Dump) HandleFunc(m *entity.Matedata) error {
log
.
Println
(
"DUMP:"
)
for
k
,
v
:=
range
(
*
m
)
.
Data
{
if
k
==
"timestamp"
{
loc
,
err
:=
time
.
LoadLocation
(
Location
)
if
err
!=
nil
{
loc
=
time
.
FixedZone
(
"CST"
,
8
*
3600
)
}
v
,
err
=
time
.
ParseInLocation
(
"2006-01-02 15:04:05 "
,
fmt
.
Sprintf
(
"%s"
,
v
),
loc
)
// 这里需要回显 假设现在是UTC-8
loc
:=
time
.
FixedZone
(
"UTC"
,
-
8
*
3600
)
createdAt
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05 "
,
fmt
.
Sprintf
(
"%s"
,
v
),
loc
)
if
err
!=
nil
{
continue
}
log
.
Println
(
"DP"
,
createdAt
)
// UTC时间就是+8小时
v
=
createdAt
.
UTC
()
.
Format
(
"2006-01-02 15:04:05"
)
}
fmt
.
Printf
(
"%s : %s
\n
"
,
k
,
v
)
}
...
...
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