@@ -1548,21 +1548,21 @@ msgid ""
15481548"As you can see, actual logging output only occurs when an event is logged "
15491549"whose severity is ERROR or greater, but in that case, any previous events at"
15501550" lower severities are also logged."
1551- msgstr "如你所见,实际日志记录输出仅在消息等级为ERROR或更高的事件时发生,但在这种情况下,任何之前较低消息等级的事件还会被记录 。"
1551+ msgstr "由上可见,只有发生 ERROR 以上级别的事件时才会实际输出日志,但之前发生的低等级事件还是会被记入日志 。"
15521552
15531553#: ../../howto/logging-cookbook.rst:2405
15541554msgid "You can of course use the conventional means of decoration::"
1555- msgstr "你当然可以使用传统的装饰方法:: "
1555+ msgstr "当然采用传统的装饰方法也是可以的: "
15561556
15571557#: ../../howto/logging-cookbook.rst:2415
15581558msgid "Formatting times using UTC (GMT) via configuration"
1559- msgstr "通过配置使用UTC ( GMT) 格式化时间 "
1559+ msgstr "通过配置将时间格式化为 UTC( GMT)格式 "
15601560
15611561#: ../../howto/logging-cookbook.rst:2417
15621562msgid ""
15631563"Sometimes you want to format times using UTC, which can be done using a "
15641564"class such as `UTCFormatter`, shown below::"
1565- msgstr "有时候,你希望使用UTC来格式化时间,这可以使用一个类来完成,例如 `UTCFormatter`,如下所示:"
1565+ msgstr "有时需要将时间格式化为 UTC 格式,可以用类似 `UTCFormatter` 的类来完成 ,如下所示:"
15661566
15671567#: ../../howto/logging-cookbook.rst:2426
15681568msgid ""
@@ -1571,9 +1571,8 @@ msgid ""
15711571"can use the :func:`~logging.config.dictConfig` API with an approach "
15721572"illustrated by the following complete example::"
15731573msgstr ""
1574- "然后你可以在你的代码中使用 ``UTCFormatter``,而不是 :class:`~logging.Formatter`。 "
1575- "如果你想通过配置来实现这一功能,你可以使用 :func:`~logging.config.dictConfig` API "
1576- "来完成,该方法在以下完整示例中展示::"
1574+ "然后自己的代码中即可采用 ``UTCFormatter`` 了,而不用 :class:`~logging.Formatter` "
1575+ "了。若要通过配置来实现,可以用 :func:`~logging.config.dictConfig` API 来完成,以下完整示例中将会演示这种方案:"
15771576
15781577#: ../../howto/logging-cookbook.rst:2469
15791578msgid "When this script is run, it should print something like:"
@@ -1583,11 +1582,11 @@ msgstr "脚本会运行输出类似下面的内容:"
15831582msgid ""
15841583"showing how the time is formatted both as local time and UTC, one for each "
15851584"handler."
1586- msgstr "展示了如何将时间格式化为本地时间和UTC两种形式,其中每种形式对应一个日志处理器 。"
1585+ msgstr "以上将时间格式化为本地时间和 UTC 两种形式,每种形式对应一个 handler 。"
15871586
15881587#: ../../howto/logging-cookbook.rst:2483
15891588msgid "Using a context manager for selective logging"
1590- msgstr "使用上下文管理器进行选择性记录 "
1589+ msgstr "用上下文管理器选择性记录日志 "
15911590
15921591#: ../../howto/logging-cookbook.rst:2485
15931592msgid ""
@@ -1598,7 +1597,8 @@ msgid ""
15981597"optionally change the logging level and add a logging handler purely in the "
15991598"scope of the context manager::"
16001599msgstr ""
1601- "有时候,我们需要暂时更改日志配置,并在执行某些操作后将其还原。为此,上下文管理器是实现保存和恢复日志上下文的最明显的方式。这是一个关于上下文管理器的简单例子,它允许你在上下文管理器的作用域内更改日志等级以及增加日志句柄:"
1600+ "有时需要临时更改日志配置,并在执行某些操作后还原配置。这时,上下文管理器正是最明显的方案,可以实现日志上下文的保存和恢复。以下是一个上下文管理器的简单示例,只在上下文管理器的作用域内更改日志等级和增加日志"
1601+ " handler:"
16021602
16031603#: ../../howto/logging-cookbook.rst:2518
16041604msgid ""
@@ -1608,15 +1608,14 @@ msgid ""
16081608" from the block. You can also ask the manager to close the handler for you "
16091609"on block exit - you could do this if you don't need the handler any more."
16101610msgstr ""
1611- "如果指定上下文管理器的日志记录等级属性,则在上下文管理器的with语句所涵盖的代码中,日志记录器的记录等级将临时设置为上下文管理器所配置的日志记录等级。"
1612- " 如果指定上下文管理的句柄属性,则该句柄在进入上下文管理器的上下文时添加到记录器中,并在退出时被删除。 "
1613- "如果你再也不需要该句柄时,你可以让上下文管理器在退出上下文管理器的上下文时关闭它。"
1611+ "如果给出了 level 值,则在上下文管理器 with 语句覆盖的作用域内,日志记录级别将设置为 level 值。如果给出了 handler "
1612+ "值,则在进入作用域时将会将其加入,离开时将会移除。如果后续用不到该 handler 了,则可在离开作用域时让上下文管理器将其关闭。"
16141613
16151614#: ../../howto/logging-cookbook.rst:2524
16161615msgid ""
16171616"To illustrate how it works, we can add the following block of code to the "
16181617"above::"
1619- msgstr "为了说明它是如何工作的,我们可以在上面添加以下代码块:: "
1618+ msgstr "为了演示上述过程,可加入以下代码: "
16201619
16211620#: ../../howto/logging-cookbook.rst:2542
16221621msgid ""
@@ -1631,26 +1630,25 @@ msgid ""
16311630"#6 appears (like message #1) whereas message #7 doesn't (just like message "
16321631"#2)."
16331632msgstr ""
1634- "我们最初设置日志记录器的消息等级为 ``INFO``,因此消息#1出现,消息#2没有出现。在接下来的 ``with``代码块中我们暂时将消息等级变更为 "
1635- "``DEBUG``,从而消息 #3 出现。在这一代码块退出后,日志记录器的消息等级恢复为 ``INFO``,从而消息 #4 没有出现 。在下一个 "
1636- "``with`` 代码块中,我们再一次将设置消息等级设置为 ``DEBUG``,同时添加一个将消息写入 ``sys.stdout`` "
1637- "的日志处理器。因此,消息#5在控制台出现两次 (分别通过 ``stderr`` 和 ``stdout``) 。在 ``with`` "
1638- "语句完成后,状态与之前一样,因此消息 #6 出现(类似消息 #1),而消息 #7 没有出现(类似消息 #2)。"
1633+ "最开始日志级别设为 ``INFO``,因此会显示 #1 信息,而 #2 信息则没有出现。接下来的 ``with`` 代码块中,暂时将日志级别变为 "
1634+ "``DEBUG``,于是 #3 信息出现了。在离开该代码块后,日志记录器的级别恢复为 ``INFO``,从而 #4 信息没有出现 。在下一个 "
1635+ "``with`` 代码块中,再次将日志级别设为 ``DEBUG``,并且加入一个写入 ``sys.stdout`` 的日志 handler。因此,#5 "
1636+ "信息在控制台出现了两次(分别由 ``stderr`` 和 ``stdout`` 显示) 。在 ``with`` 语句执行完毕后,状态复原,因此显示了 #6 "
1637+ " 信息(类似 #1),而 #7 信息没有出现(类似 #2)。"
16391638
16401639#: ../../howto/logging-cookbook.rst:2552
16411640msgid "If we run the resulting script, the result is as follows:"
1642- msgstr "如果我们运行生成的脚本,结果如下 :"
1641+ msgstr "运行结果如下 :"
16431642
16441643#: ../../howto/logging-cookbook.rst:2563
16451644msgid ""
16461645"If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the "
16471646"following, which is the only message written to ``stdout``:"
1648- msgstr ""
1649- "我们将stderr标准错误传输到/dev/null,我再次运行生成的脚步,唯一被写入stdout标准输出的消息,即我们所能看见的消息,如下:"
1647+ msgstr "但若将 ``stderr`` 重定向到 ``/dev/null``,再次运行一下,写入 ``stdout`` 的将只有以下信息:"
16501648
16511649#: ../../howto/logging-cookbook.rst:2571
16521650msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:"
1653- msgstr "再一次,将 ``stdout`` 标准输出重定向到 ``/dev/null``,我获得如下结果 :"
1651+ msgstr "再把 ``stdout`` 重定向到 ``/dev/null``,结果将如下所示 :"
16541652
16551653#: ../../howto/logging-cookbook.rst:2581
16561654msgid ""
0 commit comments