Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
looyolo
scrapy
提交
4fa833c8
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,发现更多精彩内容 >>
提交
4fa833c8
编写于
3月 24, 2010
作者:
P
Pablo Hoffman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added LOG_ENCODING setting
上级
87e68e74
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
5 deletion
+27
-5
docs/topics/logging.rst
docs/topics/logging.rst
+11
-0
docs/topics/settings.rst
docs/topics/settings.rst
+10
-1
scrapy/log.py
scrapy/log.py
+6
-4
未找到文件。
docs/topics/logging.rst
浏览文件 @
4fa833c8
...
...
@@ -129,3 +129,14 @@ scrapy.log module
Log level for debugging messages (recommended level for development)
Logging settings
================
These settings can be used to configure the logging:
* :setting:`LOG_ENABLED`
* :setting:`LOG_ENCODING`
* :setting:`LOG_FILE`
* :setting:`LOG_LEVEL`
* :setting:`LOG_STDOUT`
docs/topics/settings.rst
浏览文件 @
4fa833c8
...
...
@@ -526,7 +526,16 @@ LOG_ENABLED
Default: ``True``
Enable logging.
Whether to enable logging.
.. setting:: LOG_ENCODING
LOG_ENCODING
------------
Default: ``'utf-8'``
The encoding to use for logging.
.. setting:: LOG_FILE
...
...
scrapy/log.py
浏览文件 @
4fa833c8
...
...
@@ -29,8 +29,9 @@ BOT_NAME = settings['BOT_NAME']
# args: message, level, spider
logmessage_received
=
object
()
# default
logging level
# default
values
log_level
=
DEBUG
log_encoding
=
'utf-8'
started
=
False
...
...
@@ -47,11 +48,12 @@ def _get_log_level(level_name_or_id=None):
def
start
(
logfile
=
None
,
loglevel
=
None
,
logstdout
=
None
):
"""Initialize and start logging facility"""
global
log_level
,
started
global
log_level
,
log_encoding
,
started
if
started
or
not
settings
.
getbool
(
'LOG_ENABLED'
):
return
log_level
=
_get_log_level
(
loglevel
)
log_encoding
=
settings
[
'LOG_ENCODING'
]
started
=
True
# set log observer
...
...
@@ -74,7 +76,7 @@ def msg(message, level=INFO, component=BOT_NAME, domain=None, spider=None):
dispatcher
.
send
(
signal
=
logmessage_received
,
message
=
message
,
level
=
level
,
\
spider
=
spider
)
system
=
domain
or
(
spider
.
domain_name
if
spider
else
component
)
msg_txt
=
unicode_to_str
(
"%s: %s"
%
(
level_names
[
level
],
message
))
msg_txt
=
unicode_to_str
(
"%s: %s"
%
(
level_names
[
level
],
message
)
,
log_encoding
)
log
.
msg
(
msg_txt
,
system
=
system
)
def
exc
(
message
,
level
=
ERROR
,
component
=
BOT_NAME
,
domain
=
None
,
spider
=
None
):
...
...
@@ -93,5 +95,5 @@ def err(_stuff=None, _why=None, **kwargs):
"use 'spider' argument instead"
,
DeprecationWarning
,
stacklevel
=
2
)
kwargs
[
'system'
]
=
domain
or
(
spider
.
domain_name
if
spider
else
component
)
if
_why
:
_why
=
unicode_to_str
(
"ERROR: %s"
%
_why
)
_why
=
unicode_to_str
(
"ERROR: %s"
%
_why
,
log_encoding
)
log
.
err
(
_stuff
,
_why
,
**
kwargs
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录