Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
looyolo
scrapy
提交
ccdd8bfb
S
scrapy
项目概览
looyolo
/
scrapy
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
scrapy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ccdd8bfb
编写于
3月 05, 2015
作者:
J
Julia Medina
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parametrize log formatting strings
上级
21b9f377
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
2 deletion
+29
-2
docs/topics/settings.rst
docs/topics/settings.rst
+25
-0
scrapy/settings/default_settings.py
scrapy/settings/default_settings.py
+2
-0
scrapy/utils/log.py
scrapy/utils/log.py
+2
-2
未找到文件。
docs/topics/settings.rst
浏览文件 @
ccdd8bfb
...
...
@@ -612,6 +612,31 @@ Default: ``None``
File name to use for logging output. If None, standard error will be used.
.. setting:: LOG_FORMAT
LOG_FORMAT
----------
Default: ``'%(asctime)s [%(name)s] %(levelname)s: %(message)s'``
String for formatting log messsages. Refer to the `Python logging documentation`_ for the whole list of available
placeholders.
.. _Python logging documentation: https://docs.python.org/2/library/logging.html#logrecord-attributes
.. setting:: LOG_DATEFORMAT
LOG_DATEFORMAT
--------------
Default: ``'%Y-%m-%d %H:%M:%S%z'``
String for formatting date/time, expansion of the ``%(asctime)s`` placeholder
in :setting:`LOG_FORMAT`. Refer to the `Python datetime documentation`_ for the whole list of available
directives.
.. _Python datetime documentation: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
.. setting:: LOG_LEVEL
LOG_LEVEL
...
...
scrapy/settings/default_settings.py
浏览文件 @
ccdd8bfb
...
...
@@ -167,6 +167,8 @@ ITEM_PIPELINES_BASE = {}
LOG_ENABLED
=
True
LOG_ENCODING
=
'utf-8'
LOG_FORMATTER
=
'scrapy.logformatter.LogFormatter'
LOG_FORMAT
=
'%(asctime)s [%(name)s] %(levelname)s: %(message)s'
LOG_DATEFORMAT
=
'%Y-%m-%d %H:%M:%S%z'
LOG_STDOUT
=
False
LOG_LEVEL
=
'DEBUG'
LOG_FILE
=
None
...
...
scrapy/utils/log.py
浏览文件 @
ccdd8bfb
...
...
@@ -86,8 +86,8 @@ def configure_logging(settings=None):
handler
=
logging
.
NullHandler
()
formatter
=
logging
.
Formatter
(
fmt
=
'%(asctime)s [%(name)s] %(levelname)s: %(message)s'
,
datefmt
=
'%Y-%m-%d %H:%M:%S%z'
fmt
=
settings
.
get
(
'LOG_FORMAT'
)
,
datefmt
=
settings
.
get
(
'LOG_DATEFORMAT'
)
)
handler
.
setFormatter
(
formatter
)
handler
.
setLevel
(
settings
.
get
(
'LOG_LEVEL'
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录