Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
looyolo
scrapy
提交
37760eb1
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,发现更多精彩内容 >>
提交
37760eb1
编写于
8月 21, 2009
作者:
P
Pablo Hoffman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improved consistency of logging settings to use LOG_*
上级
f0689a9e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
31 deletion
+31
-31
docs/topics/logging.rst
docs/topics/logging.rst
+4
-4
docs/topics/settings.rst
docs/topics/settings.rst
+16
-16
scrapy/command/models.py
scrapy/command/models.py
+2
-2
scrapy/conf/commands/shell.py
scrapy/conf/commands/shell.py
+1
-1
scrapy/conf/default_settings.py
scrapy/conf/default_settings.py
+2
-2
scrapy/log.py
scrapy/log.py
+5
-5
scrapy/stats/corestats.py
scrapy/stats/corestats.py
+1
-1
未找到文件。
docs/topics/logging.rst
浏览文件 @
37760eb1
...
...
@@ -29,7 +29,7 @@ How to set the log level
========================
You can set the log level using the `--loglevel/-L` command line option, or
using the :setting:`LOGLEVEL` setting.
using the :setting:`LOG
_
LEVEL` setting.
How to log messages
===================
...
...
@@ -61,14 +61,14 @@ scrapy.log module
A boolean which is ``True`` is logging has been started or ``False`` otherwise.
.. function:: start(logfile=None, loglevel=None, log
_
stdout=None)
.. function:: start(logfile=None, loglevel=None, logstdout=None)
Start the logging facility. This must be called before actually logging any
messages. Otherwise, messages logged before this call will get lost.
``logfile`` is a string with the file path to use for logging output. If
omitted, :setting:`LOGFILE` setting will be used. If both are ``None``, log
will be sent to standard output (if ``log
_
stdout`` or :setting:`LOG_STDOUT` is
omitted, :setting:`LOG
_
FILE` setting will be used. If both are ``None``, log
will be sent to standard output (if ``logstdout`` or :setting:`LOG_STDOUT` is
``True``) or standard error (if ``log_stderr`` or :setting:`LOG_STDOUT` is
``False``).
...
...
docs/topics/settings.rst
浏览文件 @
37760eb1
...
...
@@ -526,36 +526,36 @@ Default: ``True``
Enable logging.
.. setting:: LOG_STDOUT
LOG_STDOUT
----------
Default: ``False``
.. setting:: LOG_FILE
If enabled logging will be sent to standard output, otherwise standard error
will be used.
.. setting:: LOGFILE
LOGFILE
-------
LOG_FILE
--------
Default: ``None``
File name to use for logging output. If None, standard input (or error) will be
used depending on the value of the LOG_STDOUT setting.
.. setting:: LOGLEVEL
.. setting:: LOG
_
LEVEL
LOGLEVEL
--------
LOG
_
LEVEL
--------
-
Default: ``'DEBUG'``
Minimum level to log. Available levels are: CRITICAL, ERROR, WARNING,
INFO, DEBUG. For more info see :ref:`topics-logging`.
.. setting:: LOG_STDOUT
LOG_STDOUT
----------
Default: ``False``
If enabled logging will be sent to standard output, otherwise standard error
will be used.
.. setting:: MAIL_FROM
MAIL_FROM
...
...
scrapy/command/models.py
浏览文件 @
37760eb1
...
...
@@ -69,11 +69,11 @@ class ScrapyCommand(object):
def
process_options
(
self
,
args
,
opts
):
if
opts
.
logfile
:
settings
.
overrides
[
'LOG_ENABLED'
]
=
True
settings
.
overrides
[
'LOGFILE'
]
=
opts
.
logfile
settings
.
overrides
[
'LOG
_
FILE'
]
=
opts
.
logfile
if
opts
.
loglevel
:
settings
.
overrides
[
'LOG_ENABLED'
]
=
True
settings
.
overrides
[
'LOGLEVEL'
]
=
opts
.
loglevel
settings
.
overrides
[
'LOG
_
LEVEL'
]
=
opts
.
loglevel
if
opts
.
nolog
:
settings
.
overrides
[
'LOG_ENABLED'
]
=
False
...
...
scrapy/conf/commands/shell.py
浏览文件 @
37760eb1
LOGLEVEL
=
'WARNING'
LOG
_
LEVEL
=
'WARNING'
scrapy/conf/default_settings.py
浏览文件 @
37760eb1
...
...
@@ -103,8 +103,8 @@ ITEM_PIPELINES = []
LOG_ENABLED
=
True
LOG_STDOUT
=
False
LOGLEVEL
=
'DEBUG'
LOGFILE
=
None
LOG
_
LEVEL
=
'DEBUG'
LOG
_
FILE
=
None
MAIL_HOST
=
'localhost'
MAIL_FROM
=
'scrapy@localhost'
...
...
scrapy/log.py
浏览文件 @
37760eb1
...
...
@@ -34,12 +34,12 @@ log_level = DEBUG
started
=
False
def
start
(
logfile
=
None
,
loglevel
=
None
,
log
_
stdout
=
None
):
def
start
(
logfile
=
None
,
loglevel
=
None
,
logstdout
=
None
):
"""Initialize and start logging facility"""
global
log_level
,
started
# set loglevel
loglevel
=
loglevel
or
settings
[
'LOGLEVEL'
]
loglevel
=
loglevel
or
settings
[
'LOG
_LEVEL'
]
or
settings
[
'LOG
LEVEL'
]
log_level
=
globals
()[
loglevel
]
if
loglevel
else
DEBUG
if
started
or
not
settings
.
getbool
(
'LOG_ENABLED'
):
return
...
...
@@ -47,11 +47,11 @@ def start(logfile=None, loglevel=None, log_stdout=None):
# set log observer
if
log
.
defaultObserver
:
# check twisted log not already started
logfile
=
logfile
or
settings
[
'LOGFILE'
]
log
_stdout
=
log_
stdout
or
settings
.
getbool
(
'LOG_STDOUT'
)
logfile
=
logfile
or
settings
[
'LOG
_FILE'
]
or
settings
[
'LOG
FILE'
]
log
stdout
=
log
stdout
or
settings
.
getbool
(
'LOG_STDOUT'
)
file
=
open
(
logfile
,
'a'
)
if
logfile
else
sys
.
stderr
log
.
startLogging
(
file
,
setStdout
=
log
_
stdout
)
log
.
startLogging
(
file
,
setStdout
=
logstdout
)
def
msg
(
message
,
level
=
INFO
,
component
=
BOT_NAME
,
domain
=
None
):
"""Log message according to the level"""
...
...
scrapy/stats/corestats.py
浏览文件 @
37760eb1
...
...
@@ -19,7 +19,7 @@ class CoreStats(object):
def
__init__
(
self
):
stats
.
set_value
(
'envinfo/user'
,
getpass
.
getuser
())
stats
.
set_value
(
'envinfo/host'
,
socket
.
gethostname
())
stats
.
set_value
(
'envinfo/logfile'
,
settings
[
'LOGFILE'
])
stats
.
set_value
(
'envinfo/logfile'
,
settings
[
'LOG
_
FILE'
])
stats
.
set_value
(
'envinfo/pid'
,
os
.
getpid
())
dispatcher
.
connect
(
self
.
stats_domain_opened
,
signal
=
stats_domain_opened
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录