Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
马玮
/
carspider
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0e83aa86
authored
Sep 01, 2017
by
马玮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add log layout
parent
4dd6a86c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
lib/DI.js
+14
-2
lib/spider/Base.js
+1
-0
No files found.
lib/DI.js
View file @
0e83aa86
...
...
@@ -26,12 +26,24 @@ class DI {
static
getLogger
()
{
const
level
=
process
.
env
.
LOG_LEVEL
||
'info'
;
const
appenders
=
(
process
.
env
.
LOG_TYPE
?
process
.
env
.
LOG_TYPE
.
split
(
','
)
:
null
)
||
[
'console'
,
'carspider'
];
const
layout
=
{
type
:
'pattern'
,
pattern
:
'%[[%d] [%p] [PID:%z] %X{user}%] %m'
,
};
// 按文件大小回滚配置,待以后备用
// { type: 'file', filename: `${__basedir}/logs/dealer/carspider.log`, maxLogSize: 10485760, backups: 3, compress: false }
log4js
.
configure
({
appenders
:
{
console
:
{
type
:
'console'
},
carspider
:
{
type
:
'dateFile'
,
filename
:
`
${
__basedir
}
/logs/dealer/carspider.log`
,
backups
:
7
},
console
:
{
type
:
'console'
,
layout
,
},
carspider
:
{
type
:
'dateFile'
,
filename
:
`
${
__basedir
}
/logs/dealer/carspider.log`
,
backups
:
7
,
layout
,
},
},
categories
:
{
default
:
{
appenders
:
appenders
,
level
:
level
}
...
...
lib/spider/Base.js
View file @
0e83aa86
...
...
@@ -16,6 +16,7 @@ class Base {
this
.
params
=
params
;
this
.
loginTimes
=
0
;
this
.
maxLoginTimes
=
3
;
logger
.
addContext
(
'user'
,
'mawei'
);
}
async
execute
()
{
...
...
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