Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
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
TestAuto
InterfaceAutoTest
Commits
a13b757a
Commit
a13b757a
authored
May 10, 2021
by
fanxun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改日志格式
parent
1529e42d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
common/utils/logger.py
+5
-2
config.py
+1
-1
No files found.
common/utils/logger.py
View file @
a13b757a
...
...
@@ -2,7 +2,7 @@
__author__
=
'fanxun'
__data__
=
"2021-05-10 15:47"
import
os
import
os
,
time
import
logging
from
logging.handlers
import
TimedRotatingFileHandler
from
config
import
BaseConfig
...
...
@@ -42,7 +42,7 @@ class LogHandler(logging.Logger):
"""
输出到文件
"""
file_name
=
os
.
path
.
join
(
LOG_PATH
,
'{name}.log'
.
format
(
name
=
self
.
name
)
)
file_name
=
os
.
path
.
join
(
LOG_PATH
,
f
'{self.name}{time.strftime(r"
%
Y
%
m
%
d
%
H
%
M
%
S", time.localtime())}.log'
)
# 设置日志回滚, 保存在log目录, 一天保存一个文件, 保留7天
file_handler
=
TimedRotatingFileHandler
(
filename
=
file_name
,
when
=
'D'
,
interval
=
1
,
backupCount
=
7
)
file_handler
.
suffix
=
'
%
Y
%
m
%
d.log'
...
...
@@ -75,6 +75,9 @@ class LogHandler(logging.Logger):
self
.
__setFileHandler__
()
logger
=
LogHandler
(
'log'
)
if
__name__
==
'__main__'
:
log
=
LogHandler
(
'test'
)
log
.
info
(
'this is a test msg'
)
...
...
config.py
View file @
a13b757a
...
...
@@ -17,7 +17,7 @@ class BaseConfig():
webhook
=
''
# 日志相关
log_path
=
r''
# 日志路径
log_path
=
r'
D:\项目\log
'
# 日志路径
class
BMCConfig
(
BaseConfig
):
...
...
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