Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
message-call-service
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邵兴业
message-call-service
Commits
8361d500
Commit
8361d500
authored
Jul 31, 2021
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 日志配置
parent
3781bc86
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
11 deletions
+45
-11
README.md
+7
-0
app.js
+3
-1
fields.yml
+35
-0
filebeat.yml
+0
-0
utils/system.js
+0
-10
No files found.
README.md
View file @
8361d500
#### 实现功能
#### 实现功能
*
消息请求失败重试
*
消息请求失败重试
*
消息请求延时发送
*
消息请求延时发送
*
全链路日志
#### 启动
#### 启动
...
@@ -89,3 +90,9 @@ method : post
...
@@ -89,3 +90,9 @@ method : post
}
}
```
```
#### filebeat 读取 日志
```
./filebeat -e -c {自定义}/filebeat.yml
```
app.js
View file @
8361d500
...
@@ -11,7 +11,7 @@ import moment from "moment"
...
@@ -11,7 +11,7 @@ import moment from "moment"
import
rabbmitmqUtil
from
"./utils/rabbitmq"
import
rabbmitmqUtil
from
"./utils/rabbitmq"
rabbmitmqUtil
.
initQueue
()
rabbmitmqUtil
.
initQueue
()
import
correlation
from
'./middleware/correlation'
import
correlation
from
'./middleware/correlation'
import
{
createNamespace
}
from
'cls-hooked'
import
{
createNamespace
,
getNamespace
}
from
'cls-hooked'
const
logNameSpace
=
createNamespace
(
'logger'
)
const
logNameSpace
=
createNamespace
(
'logger'
)
...
@@ -47,6 +47,8 @@ app.use(correlation(logNameSpace));
...
@@ -47,6 +47,8 @@ app.use(correlation(logNameSpace));
app
.
use
(
async
(
ctx
,
next
)
=>
{
app
.
use
(
async
(
ctx
,
next
)
=>
{
const
start
=
new
Date
()
const
start
=
new
Date
()
await
next
()
await
next
()
const
logNameSpace
=
getNamespace
(
'logger'
);
ctx
.
response
.
body
.
requestId
=
logNameSpace
.
get
(
"requestId"
)
logger
.
info
({
logger
.
info
({
request
:
ctx
.
request
,
request
:
ctx
.
request
,
response
:
ctx
.
body
,
response
:
ctx
.
body
,
...
...
fields.yml
0 → 100644
View file @
8361d500
# WARNING! Do not edit this file directly, it was generated by the ECS project,
# based on ECS version 1.9.0.
# Please visit https://github.com/elastic/ecs to suggest changes to ECS fields.
-
key
:
ecs
title
:
ECS
description
:
ECS Fields.
fields
:
-
name
:
timestamp
level
:
core
required
:
true
type
:
date
description
:
'
Date/time
when
the
event
originated.
This
is
the
date/time
extracted
from
the
event,
typically
representing
when
the
event
was
generated
by
the
source.
If
the
event
source
has
no
original
timestamp,
this
value
is
typically
populated
by
the
first
time
the
event
was
received
by
the
pipeline.
Required
field
for
all
events.'
example
:
'
2016-05-23T08:05:34.853Z'
-
name
:
level
level
:
core
type
:
keyword
-
name
:
serverName
level
:
core
type
:
keyword
-
name
:
requestId
level
:
core
type
:
keyword
-
name
:
message
level
:
core
type
:
keyword
\ No newline at end of file
filebeat.yml
View file @
8361d500
This diff is collapsed.
Click to expand it.
utils/system.js
View file @
8361d500
import
{
getNamespace
}
from
'cls-hooked'
;
export
const
ok
=
(
data
)
=>
{
export
const
ok
=
(
data
)
=>
{
const
logNameSpace
=
getNamespace
(
'logger'
);
return
{
return
{
code
:
0
,
code
:
0
,
success
:
true
,
success
:
true
,
message
:
null
,
message
:
null
,
data
,
data
,
requestId
:
logNameSpace
.
get
(
"requestId"
),
}
}
}
}
export
const
error
=
(
msg
=
"未知错误"
,
code
=
-
1
)
=>
{
export
const
error
=
(
msg
=
"未知错误"
,
code
=
-
1
)
=>
{
const
logNameSpace
=
getNamespace
(
'logger'
);
return
{
return
{
code
,
code
,
success
:
false
,
success
:
false
,
message
:
msg
,
message
:
msg
,
data
:
null
,
data
:
null
,
requestId
:
logNameSpace
.
get
(
"requestId"
),
}
}
}
}
\ No newline at end of file
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