@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.11\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2024-02-23 16:44 +0000\n "
14+ "POT-Creation-Date : 2024-03-15 16:48 +0000\n "
1515"PO-Revision-Date : 2023-05-24 02:11+0000\n "
1616"
Last-Translator :
Rafael Fontenelle <[email protected] >, 2024\n "
1717"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1254,27 +1254,27 @@ msgstr ""
12541254"你还可以子类化 :class:`QueueListener` 来从其他类型的队列中获取消息,比如从 ZeroMQ 'subscribe' 套接字。 "
12551255"下面是一个例子::"
12561256
1257- #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3950
1257+ #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3973
12581258msgid "Module :mod:`logging`"
12591259msgstr "模块 :mod:`logging`"
12601260
1261- #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3950
1261+ #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3973
12621262msgid "API reference for the logging module."
12631263msgstr "日志记录模块的 API 参考。"
12641264
1265- #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3953
1265+ #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3976
12661266msgid "Module :mod:`logging.config`"
12671267msgstr ":mod:`logging.config` 模块"
12681268
1269- #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3953
1269+ #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3976
12701270msgid "Configuration API for the logging module."
12711271msgstr "日志记录模块的配置 API 。"
12721272
1273- #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3956
1273+ #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3979
12741274msgid "Module :mod:`logging.handlers`"
12751275msgstr ":mod:`logging.handlers` 模块"
12761276
1277- #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3956
1277+ #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3979
12781278msgid "Useful handlers included with the logging module."
12791279msgstr "日志记录模块附带的有用处理器。"
12801280
@@ -2172,17 +2172,17 @@ msgstr ""
21722172
21732173#: ../../howto/logging-cookbook.rst:3421
21742174msgid ""
2175- "The code should work with recent releases of either ``PySide2`` or "
2176- "``PyQt5``. You should be able to adapt the approach to earlier versions of "
2177- "Qt. Please refer to the comments in the code snippet for more detailed "
2178- "information."
2179- msgstr "以下代码应能适用于最新版的 ``PySide2`` 或 ``PyQt5``。对于低版本的 Qt 应该也能适用。更多详情,请参阅代码注释。 "
2175+ "The code should work with recent releases of either ``PySide6``, ``PyQt6``, "
2176+ "``PySide2`` or `` PyQt5``. You should be able to adapt the approach to "
2177+ "earlier versions of Qt. Please refer to the comments in the code snippet for"
2178+ " more detailed information."
2179+ msgstr ""
21802180
2181- #: ../../howto/logging-cookbook.rst:3635
2181+ #: ../../howto/logging-cookbook.rst:3658
21822182msgid "Logging to syslog with RFC5424 support"
21832183msgstr "将日志记录到带有 RFC5424 支持的 syslog"
21842184
2185- #: ../../howto/logging-cookbook.rst:3637
2185+ #: ../../howto/logging-cookbook.rst:3660
21862186msgid ""
21872187"Although :rfc:`5424` dates from 2009, most syslog servers are configured by "
21882188"detault to use the older :rfc:`3164`, which hails from 2001. When "
@@ -2196,7 +2196,7 @@ msgstr ""
21962196"诞生后,它还没有被广泛部署到 syslog 服务器上,因此 :class:`~logging.handlers.SysLogHandler` "
21972197"的功能也没有被更新。"
21982198
2199- #: ../../howto/logging-cookbook.rst:3644
2199+ #: ../../howto/logging-cookbook.rst:3667
22002200msgid ""
22012201"RFC 5424 contains some useful features such as support for structured data, "
22022202"and if you need to be able to log to a syslog server with support for it, "
@@ -2205,7 +2205,7 @@ msgstr ""
22052205"RFC 5424 包括一些有用的特性例如对结构化数据的支持等,如果你想要能够将日志记录到带有该协议支持的 syslog "
22062206"服务器上,你可以使用一个看起来像是这样的子类化处理句柄来实现::"
22072207
2208- #: ../../howto/logging-cookbook.rst:3710
2208+ #: ../../howto/logging-cookbook.rst:3733
22092209msgid ""
22102210"You'll need to be familiar with RFC 5424 to fully understand the above code,"
22112211" and it may be that you have slightly different needs (e.g. for how you pass"
@@ -2216,11 +2216,11 @@ msgstr ""
22162216"你需要熟悉 RFC 5424 才能完全理解上面的代码,你还可能会有稍加变化的的需求(例如你要如何将结构化数据记入日志)。 "
22172217"不管怎样,上面的代码应当根据你的特定需求来灵活调整。 通过上面的处理句柄,你可以使用类似这样的代码来传入结构化数据::"
22182218
2219- #: ../../howto/logging-cookbook.rst:3724
2219+ #: ../../howto/logging-cookbook.rst:3747
22202220msgid "How to treat a logger like an output stream"
22212221msgstr "如何将日志记录器作为输出流"
22222222
2223- #: ../../howto/logging-cookbook.rst:3726
2223+ #: ../../howto/logging-cookbook.rst:3749
22242224msgid ""
22252225"Sometimes, you need to interface to a third-party API which expects a file-"
22262226"like object to write to, but you want to direct the API's output to a "
@@ -2230,18 +2230,18 @@ msgstr ""
22302230"有时,你需要通过接口访问某个预期要写入到文件型对象第三方 API,但你希望将 API 的输出重定向到一个日志记录器。 你可以使用一个以文件类 API "
22312231"来包装日志记录器的类。 下面是一个演示这样的类的简短脚本:"
22322232
2233- #: ../../howto/logging-cookbook.rst:3766
2233+ #: ../../howto/logging-cookbook.rst:3789
22342234msgid "When this script is run, it prints"
22352235msgstr "当此脚本运行时,它将打印"
22362236
2237- #: ../../howto/logging-cookbook.rst:3773
2237+ #: ../../howto/logging-cookbook.rst:3796
22382238msgid ""
22392239"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and "
22402240"``sys.stderr`` by doing something like this:"
22412241msgstr ""
22422242"你还可以使用 ``LoggerWriter`` 通过下面这样的做法来重定向 ``sys.stdout`` 和 ``sys.stderr``:"
22432243
2244- #: ../../howto/logging-cookbook.rst:3783
2244+ #: ../../howto/logging-cookbook.rst:3806
22452245msgid ""
22462246"You should do this *after* configuring logging for your needs. In the above "
22472247"example, the :func:`~logging.basicConfig` call does this (using the "
@@ -2251,15 +2251,15 @@ msgstr ""
22512251"你应当在根据需要配置日志记录 *之后* 再这样做。 在上面的例子中,:func:`~logging.basicConfig` 调用执行了此操作(在 "
22522252"``sys.stderr`` 被一个 ``LoggerWriter`` 实例覆盖 *之前* 使用它的值)。 然后,你将得到这样的结果:"
22532253
2254- #: ../../howto/logging-cookbook.rst:3796
2254+ #: ../../howto/logging-cookbook.rst:3819
22552255msgid ""
22562256"Of course, the examples above show output according to the format used by "
22572257":func:`~logging.basicConfig`, but you can use a different formatter when you"
22582258" configure logging."
22592259msgstr ""
22602260"当然,上面的例子是按照 :func:`~logging.basicConfig` 所使用的格式来显示输出的,但你也可以在配置日志记录时使用其他的格式。"
22612261
2262- #: ../../howto/logging-cookbook.rst:3800
2262+ #: ../../howto/logging-cookbook.rst:3823
22632263msgid ""
22642264"Note that with the above scheme, you are somewhat at the mercy of buffering "
22652265"and the sequence of write calls which you are intercepting. For example, "
@@ -2268,11 +2268,11 @@ msgstr ""
22682268"请注意当使用上面的预置方案时,你将在一定程度上受到你所拦截的写入调用的缓冲和顺序的控制。 例如,在使用上述 ``LoggerWriter`` "
22692269"的定义的情况下,如果你使用代码段"
22702270
2271- #: ../../howto/logging-cookbook.rst:3809
2271+ #: ../../howto/logging-cookbook.rst:3832
22722272msgid "then running the script results in"
22732273msgstr "则运行该脚本的结果为"
22742274
2275- #: ../../howto/logging-cookbook.rst:3827
2275+ #: ../../howto/logging-cookbook.rst:3850
22762276msgid ""
22772277"As you can see, this output isn't ideal. That's because the underlying code "
22782278"which writes to ``sys.stderr`` makes mutiple writes, each of which results "
@@ -2285,17 +2285,17 @@ msgstr ""
22852285"的代码会执行多次写入,每次写入将产生一条单独的日志记录行(例如,上面的最后三行)。 要避免这个问题,你需要使用缓冲并且只在看到换行符时才输出日志记录行。"
22862286" 让我们使用一个更好些的 ``LoggerWriter`` 实现:"
22872287
2288- #: ../../howto/logging-cookbook.rst:3852
2288+ #: ../../howto/logging-cookbook.rst:3875
22892289msgid ""
22902290"This just buffers up stuff until a newline is seen, and then logs complete "
22912291"lines. With this approach, you get better output:"
22922292msgstr "这段代码对内容进行了缓冲直至遇到换行符,然后将完整的行写入日志记录。 通过这种方式,你将得到更好的输出:"
22932293
2294- #: ../../howto/logging-cookbook.rst:3868
2294+ #: ../../howto/logging-cookbook.rst:3891
22952295msgid "Patterns to avoid"
22962296msgstr "理应避免的用法"
22972297
2298- #: ../../howto/logging-cookbook.rst:3870
2298+ #: ../../howto/logging-cookbook.rst:3893
22992299msgid ""
23002300"Although the preceding sections have described ways of doing things you "
23012301"might need to do or deal with, it is worth mentioning some usage patterns "
@@ -2304,11 +2304,11 @@ msgid ""
23042304msgstr ""
23052305"前几节虽介绍了几种方案,描述了可能需要处理的操作,但值得一提的是,有些用法是 *没有好处* 的,大多数情况下应该避免使用。下面几节的顺序不分先后。"
23062306
2307- #: ../../howto/logging-cookbook.rst:3876
2307+ #: ../../howto/logging-cookbook.rst:3899
23082308msgid "Opening the same log file multiple times"
23092309msgstr "多次打开同一个日志文件"
23102310
2311- #: ../../howto/logging-cookbook.rst:3878
2311+ #: ../../howto/logging-cookbook.rst:3901
23122312msgid ""
23132313"On Windows, you will generally not be able to open the same file multiple "
23142314"times as this will lead to a \" file is in use by another process\" error. "
@@ -2318,33 +2318,33 @@ msgstr ""
23182318"因会导致 \" 文件被其他进程占用 \" 错误,所以在 Windows 中一般无法多次打开同一个文件。但在 POSIX "
23192319"平台中,多次打开同一个文件不会报任何错误。这种操作可能是意外发生的,比如:"
23202320
2321- #: ../../howto/logging-cookbook.rst:3883
2321+ #: ../../howto/logging-cookbook.rst:3906
23222322msgid ""
23232323"Adding a file handler more than once which references the same file (e.g. by"
23242324" a copy/paste/forget-to-change error)."
23252325msgstr "多次添加指向同一文件的 handler(比如通过复制/粘贴,或忘记修改)。"
23262326
2327- #: ../../howto/logging-cookbook.rst:3886
2327+ #: ../../howto/logging-cookbook.rst:3909
23282328msgid ""
23292329"Opening two files that look different, as they have different names, but are"
23302330" the same because one is a symbolic link to the other."
23312331msgstr "打开两个貌似不同(文件名不一样)的文件,但一个是另一个的符号链接,所以其实是同一个文件。"
23322332
2333- #: ../../howto/logging-cookbook.rst:3889
2333+ #: ../../howto/logging-cookbook.rst:3912
23342334msgid ""
23352335"Forking a process, following which both parent and child have a reference to"
23362336" the same file. This might be through use of the :mod:`multiprocessing` "
23372337"module, for example."
23382338msgstr ""
23392339"进程 fork,然后父进程和子进程都有对同一文件的引用。 例如,这可能是通过使用 :mod:`multiprocessing` 模块实现的。"
23402340
2341- #: ../../howto/logging-cookbook.rst:3893
2341+ #: ../../howto/logging-cookbook.rst:3916
23422342msgid ""
23432343"Opening a file multiple times might *appear* to work most of the time, but "
23442344"can lead to a number of problems in practice:"
23452345msgstr "在大多数情况下,多次打开同一个文件 *貌似* 一切正常,但实际会导致很多问题。"
23462346
2347- #: ../../howto/logging-cookbook.rst:3896
2347+ #: ../../howto/logging-cookbook.rst:3919
23482348msgid ""
23492349"Logging output can be garbled because multiple threads or processes try to "
23502350"write to the same file. Although logging guards against concurrent use of "
@@ -2355,7 +2355,7 @@ msgstr ""
23552355"由于多个线程或进程会尝试写入同一个文件,日志输出可能会出现乱码。尽管日志对象可以防止多个线程同时使用同一个 handler "
23562356"实例,但如果两个不同的线程使用不同的 handler 实例同时写入文件,而这两个 handler 又恰好指向同一个文件,那么就失去了这种防护。"
23572357
2358- #: ../../howto/logging-cookbook.rst:3902
2358+ #: ../../howto/logging-cookbook.rst:3925
23592359msgid ""
23602360"An attempt to delete a file (e.g. during file rotation) silently fails, "
23612361"because there is another reference pointing to it. This can lead to "
@@ -2368,17 +2368,17 @@ msgstr ""
23682368"日志条目会出现在意想不到的地方,或者完全丢失。 "
23692369"或者会有应当移除的文件仍然保持存在,文件还会在已经设置了基于文件大小的轮换的情况下仍然增长到预料之外的大小。"
23702370
2371- #: ../../howto/logging-cookbook.rst:3909
2371+ #: ../../howto/logging-cookbook.rst:3932
23722372msgid ""
23732373"Use the techniques outlined in :ref:`multiple-processes` to circumvent such "
23742374"issues."
23752375msgstr "请用 :ref:`multiple-processes` 中介绍的技术来避免上述问题。"
23762376
2377- #: ../../howto/logging-cookbook.rst:3913
2377+ #: ../../howto/logging-cookbook.rst:3936
23782378msgid "Using loggers as attributes in a class or passing them as parameters"
23792379msgstr "将日志对象用作属性或传递参数"
23802380
2381- #: ../../howto/logging-cookbook.rst:3915
2381+ #: ../../howto/logging-cookbook.rst:3938
23822382msgid ""
23832383"While there might be unusual cases where you'll need to do this, in general "
23842384"there is no point because loggers are singletons. Code can always access a "
@@ -2392,13 +2392,13 @@ msgstr ""
23922392"用名称访问一个已有的日志对象实例,因此将实例作为参数来传递,或作为属性留存,都是毫无意义的。请注意,在其他语言中,如 Java 和 "
23932393"C#,日志对象通常是静态类属性。但在 Python 中是没有意义的,因为软件拆分的单位是模块(而不是类)。"
23942394
2395- #: ../../howto/logging-cookbook.rst:3924
2395+ #: ../../howto/logging-cookbook.rst:3947
23962396msgid ""
23972397"Adding handlers other than :class:`~logging.NullHandler` to a logger in a "
23982398"library"
23992399msgstr "为库中的日志记录器添加 :class:`~logging.NullHandler` 以外的处理句柄"
24002400
2401- #: ../../howto/logging-cookbook.rst:3926
2401+ #: ../../howto/logging-cookbook.rst:3949
24022402msgid ""
24032403"Configuring logging by adding handlers, formatters and filters is the "
24042404"responsibility of the application developer, not the library developer. If "
@@ -2409,11 +2409,11 @@ msgstr ""
24092409"来配置日志,这是应用程序开发人员的责任,而不是库开发人员该做的。如果正在维护一个库,请确保不要向任何日志对象添加 "
24102410":class:`~logging.NullHandler` 实例以外的 handler。"
24112411
2412- #: ../../howto/logging-cookbook.rst:3932
2412+ #: ../../howto/logging-cookbook.rst:3955
24132413msgid "Creating a lot of loggers"
24142414msgstr "创建大量的日志对象"
24152415
2416- #: ../../howto/logging-cookbook.rst:3934
2416+ #: ../../howto/logging-cookbook.rst:3957
24172417msgid ""
24182418"Loggers are singletons that are never freed during a script execution, and "
24192419"so creating lots of loggers will use up memory which can't then be freed. "
@@ -2427,14 +2427,14 @@ msgstr ""
24272427" :ref:`已有机制 <context-info>` "
24282428"将上下文信息传给自定义日志对象,并将创建的日志对象限制在应用程序内的指定区域(通常是模块,但偶尔会再精细些)使用。"
24292429
2430- #: ../../howto/logging-cookbook.rst:3945
2430+ #: ../../howto/logging-cookbook.rst:3968
24312431msgid "Other resources"
24322432msgstr "其他资源"
24332433
2434- #: ../../howto/logging-cookbook.rst:3958
2434+ #: ../../howto/logging-cookbook.rst:3981
24352435msgid ":ref:`Basic Tutorial <logging-basic-tutorial>`"
24362436msgstr ":ref:`基础教程 <logging-basic-tutorial>`"
24372437
2438- #: ../../howto/logging-cookbook.rst:3960
2438+ #: ../../howto/logging-cookbook.rst:3983
24392439msgid ":ref:`Advanced Tutorial <logging-advanced-tutorial>`"
24402440msgstr ":ref:`进阶教程 <logging-advanced-tutorial>`"
0 commit comments