File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -646,7 +646,7 @@ msgid ""
646646"Note that the formatting of logging messages for final output to logs is "
647647"completely independent of how an individual logging message is constructed. "
648648"That can still use %-formatting, as shown here::"
649- msgstr "请注意,最终输出到日志的信息格式与某一条信息的构造方式完全独立。某条信息仍然可以采用 %-f 格式,如下所示:"
649+ msgstr "请注意,最终输出到日志的信息格式与某一条信息的构造方式完全独立。单条信息仍然可以采用 %-f 格式,如下所示:"
650650
651651#: ../../howto/logging-cookbook.rst:1097
652652msgid ""
@@ -663,6 +663,11 @@ msgid ""
663663" logging calls which are out there in existing code will be using %-format "
664664"strings."
665665msgstr ""
666+ "日志调用(``logger.debug()`` 、``logger.info()`` "
667+ "等)接受的位置参数只会用于日志信息本身,而关键字参数仅用于日志调用的可选处理参数(如关键字参数 ``exc_info`` 表示应记录跟踪信息, "
668+ "``extra`` 则标识了需要加入日志的额外上下文信息)。所以不能直接用 :meth:`str.format` 或 "
669+ ":class:`string.Template` 语法进行日志调用,因为日志包在内部使用 %-f "
670+ "格式来合并格式串和参数变量。在保持向下兼容性时,这一点不会改变,因为已有代码中的所有日志调用都会使用%-f 格式串。"
666671
667672#: ../../howto/logging-cookbook.rst:1110
668673msgid ""
@@ -672,6 +677,8 @@ msgid ""
672677"will call ``str()`` on that object to get the actual format string. Consider"
673678" the following two classes::"
674679msgstr ""
680+ "还有一种方法可以构建自己的日志信息,就是利用 {}- 和 $- 格式。回想一下,任意对象都可用为日志信息的格式串,日志包将会调用该对象的 "
681+ "``str()`` 方法,以获取最终的格式串。不妨看下一下两个类:"
675682
676683#: ../../howto/logging-cookbook.rst:1134
677684msgid ""
You can’t perform that action at this time.
0 commit comments