@@ -23,7 +23,7 @@ msgid ""
2323msgstr ""
2424"Project-Id-Version : Python 3.12\n "
2525"Report-Msgid-Bugs-To : \n "
26- "POT-Creation-Date : 2024-02-16 14:13+0000\n "
26+ "POT-Creation-Date : 2024-03-15 14:13+0000\n "
2727"PO-Revision-Date : 2021-06-28 00:53+0000\n "
2828"
Last-Translator :
Freesand Leo <[email protected] >, 2024\n "
2929"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1266,27 +1266,27 @@ msgstr ""
12661266"你还可以子类化 :class:`QueueListener` 来从其他类型的队列中获取消息,比如从 ZeroMQ 'subscribe' 套接字。 "
12671267"下面是一个例子::"
12681268
1269- #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3950
1269+ #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3973
12701270msgid "Module :mod:`logging`"
12711271msgstr "模块 :mod:`logging`"
12721272
1273- #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3950
1273+ #: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:3973
12741274msgid "API reference for the logging module."
12751275msgstr "日志记录模块的 API 参考。"
12761276
1277- #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3953
1277+ #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3976
12781278msgid "Module :mod:`logging.config`"
12791279msgstr ":mod:`logging.config` 模块"
12801280
1281- #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3953
1281+ #: ../../howto/logging-cookbook.rst:1913 ../../howto/logging-cookbook.rst:3976
12821282msgid "Configuration API for the logging module."
12831283msgstr "日志记录模块的配置 API 。"
12841284
1285- #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3956
1285+ #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3979
12861286msgid "Module :mod:`logging.handlers`"
12871287msgstr ":mod:`logging.handlers` 模块"
12881288
1289- #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3956
1289+ #: ../../howto/logging-cookbook.rst:1916 ../../howto/logging-cookbook.rst:3979
12901290msgid "Useful handlers included with the logging module."
12911291msgstr "日志记录模块附带的有用处理器。"
12921292
@@ -2184,17 +2184,17 @@ msgstr ""
21842184
21852185#: ../../howto/logging-cookbook.rst:3421
21862186msgid ""
2187- "The code should work with recent releases of either ``PySide2`` or "
2188- "``PyQt5``. You should be able to adapt the approach to earlier versions of "
2189- "Qt. Please refer to the comments in the code snippet for more detailed "
2190- "information."
2191- msgstr "以下代码应能适用于最新版的 ``PySide2`` 或 ``PyQt5``。对于低版本的 Qt 应该也能适用。更多详情,请参阅代码注释。 "
2187+ "The code should work with recent releases of either ``PySide6``, ``PyQt6``, "
2188+ "``PySide2`` or `` PyQt5``. You should be able to adapt the approach to "
2189+ "earlier versions of Qt. Please refer to the comments in the code snippet for"
2190+ " more detailed information."
2191+ msgstr ""
21922192
2193- #: ../../howto/logging-cookbook.rst:3635
2193+ #: ../../howto/logging-cookbook.rst:3658
21942194msgid "Logging to syslog with RFC5424 support"
21952195msgstr "将日志记录到带有 RFC5424 支持的 syslog"
21962196
2197- #: ../../howto/logging-cookbook.rst:3637
2197+ #: ../../howto/logging-cookbook.rst:3660
21982198msgid ""
21992199"Although :rfc:`5424` dates from 2009, most syslog servers are configured by "
22002200"default to use the older :rfc:`3164`, which hails from 2001. When "
@@ -2208,7 +2208,7 @@ msgstr ""
22082208"发布后,因为它还未被广泛部署到 syslog 服务器上,因此 :class:`~logging.handlers.SysLogHandler` "
22092209"的功能也没有被更新。"
22102210
2211- #: ../../howto/logging-cookbook.rst:3644
2211+ #: ../../howto/logging-cookbook.rst:3667
22122212msgid ""
22132213"RFC 5424 contains some useful features such as support for structured data, "
22142214"and if you need to be able to log to a syslog server with support for it, "
@@ -2217,7 +2217,7 @@ msgstr ""
22172217"RFC 5424 包括一些有用的特性例如对结构化数据的支持等,如果你想要能够将日志记录到带有该协议支持的 syslog "
22182218"服务器上,你可以使用一个看起来像是这样的子类化处理句柄来实现::"
22192219
2220- #: ../../howto/logging-cookbook.rst:3710
2220+ #: ../../howto/logging-cookbook.rst:3733
22212221msgid ""
22222222"You'll need to be familiar with RFC 5424 to fully understand the above code,"
22232223" and it may be that you have slightly different needs (e.g. for how you pass"
@@ -2228,11 +2228,11 @@ msgstr ""
22282228"你需要熟悉 RFC 5424 才能完全理解上面的代码,你还可能会有稍加变化的的需求(例如你要如何将结构化数据记入日志)。 "
22292229"不管怎样,上面的代码应当根据你的特定需求来灵活调整。 通过上面的处理句柄,你可以使用类似这样的代码来传入结构化数据::"
22302230
2231- #: ../../howto/logging-cookbook.rst:3724
2231+ #: ../../howto/logging-cookbook.rst:3747
22322232msgid "How to treat a logger like an output stream"
22332233msgstr "如何将日志记录器作为输出流"
22342234
2235- #: ../../howto/logging-cookbook.rst:3726
2235+ #: ../../howto/logging-cookbook.rst:3749
22362236msgid ""
22372237"Sometimes, you need to interface to a third-party API which expects a file-"
22382238"like object to write to, but you want to direct the API's output to a "
@@ -2242,18 +2242,18 @@ msgstr ""
22422242"有时,你需要通过接口访问某个预期要写入到文件型对象第三方 API,但你希望将 API 的输出重定向到一个日志记录器。 你可以使用一个以文件类 API "
22432243"来包装日志记录器的类。 下面是一个演示这样的类的简短脚本:"
22442244
2245- #: ../../howto/logging-cookbook.rst:3766
2245+ #: ../../howto/logging-cookbook.rst:3789
22462246msgid "When this script is run, it prints"
22472247msgstr "当此脚本运行时,它将打印"
22482248
2249- #: ../../howto/logging-cookbook.rst:3773
2249+ #: ../../howto/logging-cookbook.rst:3796
22502250msgid ""
22512251"You could also use ``LoggerWriter`` to redirect ``sys.stdout`` and "
22522252"``sys.stderr`` by doing something like this:"
22532253msgstr ""
22542254"你还可以使用 ``LoggerWriter`` 通过下面这样的做法来重定向 ``sys.stdout`` 和 ``sys.stderr``:"
22552255
2256- #: ../../howto/logging-cookbook.rst:3783
2256+ #: ../../howto/logging-cookbook.rst:3806
22572257msgid ""
22582258"You should do this *after* configuring logging for your needs. In the above "
22592259"example, the :func:`~logging.basicConfig` call does this (using the "
@@ -2263,15 +2263,15 @@ msgstr ""
22632263"你应当在根据需要配置日志记录 *之后* 再这样做。 在上面的例子中,:func:`~logging.basicConfig` 调用执行了此操作(在 "
22642264"``sys.stderr`` 被一个 ``LoggerWriter`` 实例覆盖 *之前* 使用它的值)。 然后,你将得到这样的结果:"
22652265
2266- #: ../../howto/logging-cookbook.rst:3796
2266+ #: ../../howto/logging-cookbook.rst:3819
22672267msgid ""
22682268"Of course, the examples above show output according to the format used by "
22692269":func:`~logging.basicConfig`, but you can use a different formatter when you"
22702270" configure logging."
22712271msgstr ""
22722272"当然,上面的例子是按照 :func:`~logging.basicConfig` 所使用的格式来显示输出的,但你也可以在配置日志记录时使用其他的格式。"
22732273
2274- #: ../../howto/logging-cookbook.rst:3800
2274+ #: ../../howto/logging-cookbook.rst:3823
22752275msgid ""
22762276"Note that with the above scheme, you are somewhat at the mercy of buffering "
22772277"and the sequence of write calls which you are intercepting. For example, "
@@ -2280,11 +2280,11 @@ msgstr ""
22802280"请注意当使用上面的预置方案时,你将在一定程度上受到你所拦截的写入调用的缓冲和顺序的控制。 例如,在使用上述 ``LoggerWriter`` "
22812281"的定义的情况下,如果你使用代码段"
22822282
2283- #: ../../howto/logging-cookbook.rst:3809
2283+ #: ../../howto/logging-cookbook.rst:3832
22842284msgid "then running the script results in"
22852285msgstr "则运行该脚本的结果为"
22862286
2287- #: ../../howto/logging-cookbook.rst:3827
2287+ #: ../../howto/logging-cookbook.rst:3850
22882288msgid ""
22892289"As you can see, this output isn't ideal. That's because the underlying code "
22902290"which writes to ``sys.stderr`` makes multiple writes, each of which results "
@@ -2297,17 +2297,17 @@ msgstr ""
22972297"的代码会执行多次写入,每次写入都将产生一条单独的日志记录行(例如,上面的最后三行)。 "
22982298"要避免这个问题,你需要使用缓冲并且只在看到换行符时才输出日志记录行。 让我们使用一个更好些的 ``LoggerWriter`` 实现:"
22992299
2300- #: ../../howto/logging-cookbook.rst:3852
2300+ #: ../../howto/logging-cookbook.rst:3875
23012301msgid ""
23022302"This just buffers up stuff until a newline is seen, and then logs complete "
23032303"lines. With this approach, you get better output:"
23042304msgstr "这段代码对内容进行了缓冲直至遇到换行符,然后将完整的行写入日志记录。 通过这种方式,你将得到更好的输出:"
23052305
2306- #: ../../howto/logging-cookbook.rst:3868
2306+ #: ../../howto/logging-cookbook.rst:3891
23072307msgid "Patterns to avoid"
23082308msgstr "理应避免的用法"
23092309
2310- #: ../../howto/logging-cookbook.rst:3870
2310+ #: ../../howto/logging-cookbook.rst:3893
23112311msgid ""
23122312"Although the preceding sections have described ways of doing things you "
23132313"might need to do or deal with, it is worth mentioning some usage patterns "
@@ -2316,11 +2316,11 @@ msgid ""
23162316msgstr ""
23172317"前几节虽介绍了几种方案,描述了可能需要处理的操作,但值得一提的是,有些用法是 *没有好处* 的,大多数情况下应该避免使用。下面几节的顺序不分先后。"
23182318
2319- #: ../../howto/logging-cookbook.rst:3876
2319+ #: ../../howto/logging-cookbook.rst:3899
23202320msgid "Opening the same log file multiple times"
23212321msgstr "多次打开同一个日志文件"
23222322
2323- #: ../../howto/logging-cookbook.rst:3878
2323+ #: ../../howto/logging-cookbook.rst:3901
23242324msgid ""
23252325"On Windows, you will generally not be able to open the same file multiple "
23262326"times as this will lead to a \" file is in use by another process\" error. "
@@ -2330,33 +2330,33 @@ msgstr ""
23302330"因会导致 \" 文件被其他进程占用 \" 错误,所以在 Windows 中一般无法多次打开同一个文件。但在 POSIX "
23312331"平台中,多次打开同一个文件不会报任何错误。这种操作可能是意外发生的,比如:"
23322332
2333- #: ../../howto/logging-cookbook.rst:3883
2333+ #: ../../howto/logging-cookbook.rst:3906
23342334msgid ""
23352335"Adding a file handler more than once which references the same file (e.g. by"
23362336" a copy/paste/forget-to-change error)."
23372337msgstr "多次添加指向同一文件的 handler(比如通过复制/粘贴,或忘记修改)。"
23382338
2339- #: ../../howto/logging-cookbook.rst:3886
2339+ #: ../../howto/logging-cookbook.rst:3909
23402340msgid ""
23412341"Opening two files that look different, as they have different names, but are"
23422342" the same because one is a symbolic link to the other."
23432343msgstr "打开两个貌似不同(文件名不一样)的文件,但一个是另一个的符号链接,所以其实是同一个文件。"
23442344
2345- #: ../../howto/logging-cookbook.rst:3889
2345+ #: ../../howto/logging-cookbook.rst:3912
23462346msgid ""
23472347"Forking a process, following which both parent and child have a reference to"
23482348" the same file. This might be through use of the :mod:`multiprocessing` "
23492349"module, for example."
23502350msgstr ""
23512351"进程 fork,然后父进程和子进程都有对同一文件的引用。 例如,这可能是通过使用 :mod:`multiprocessing` 模块实现的。"
23522352
2353- #: ../../howto/logging-cookbook.rst:3893
2353+ #: ../../howto/logging-cookbook.rst:3916
23542354msgid ""
23552355"Opening a file multiple times might *appear* to work most of the time, but "
23562356"can lead to a number of problems in practice:"
23572357msgstr "在大多数情况下,多次打开同一个文件 *貌似* 一切正常,但实际会导致很多问题。"
23582358
2359- #: ../../howto/logging-cookbook.rst:3896
2359+ #: ../../howto/logging-cookbook.rst:3919
23602360msgid ""
23612361"Logging output can be garbled because multiple threads or processes try to "
23622362"write to the same file. Although logging guards against concurrent use of "
@@ -2367,7 +2367,7 @@ msgstr ""
23672367"由于多个线程或进程会尝试写入同一个文件,日志输出可能会出现乱码。尽管日志对象可以防止多个线程同时使用同一个 handler "
23682368"实例,但如果两个不同的线程使用不同的 handler 实例同时写入文件,而这两个 handler 又恰好指向同一个文件,那么就失去了这种防护。"
23692369
2370- #: ../../howto/logging-cookbook.rst:3902
2370+ #: ../../howto/logging-cookbook.rst:3925
23712371msgid ""
23722372"An attempt to delete a file (e.g. during file rotation) silently fails, "
23732373"because there is another reference pointing to it. This can lead to "
@@ -2380,17 +2380,17 @@ msgstr ""
23802380"日志条目会出现在意想不到的地方,或者完全丢失。 "
23812381"或者会有应当移除的文件仍然保持存在,文件还会在已经设置了基于文件大小的轮换的情况下仍然增长到预料之外的大小。"
23822382
2383- #: ../../howto/logging-cookbook.rst:3909
2383+ #: ../../howto/logging-cookbook.rst:3932
23842384msgid ""
23852385"Use the techniques outlined in :ref:`multiple-processes` to circumvent such "
23862386"issues."
23872387msgstr "请用 :ref:`multiple-processes` 中介绍的技术来避免上述问题。"
23882388
2389- #: ../../howto/logging-cookbook.rst:3913
2389+ #: ../../howto/logging-cookbook.rst:3936
23902390msgid "Using loggers as attributes in a class or passing them as parameters"
23912391msgstr "将日志对象用作属性或传递参数"
23922392
2393- #: ../../howto/logging-cookbook.rst:3915
2393+ #: ../../howto/logging-cookbook.rst:3938
23942394msgid ""
23952395"While there might be unusual cases where you'll need to do this, in general "
23962396"there is no point because loggers are singletons. Code can always access a "
@@ -2404,13 +2404,13 @@ msgstr ""
24042404"用名称访问一个已有的日志对象实例,因此将实例作为参数来传递,或作为属性留存,都是毫无意义的。请注意,在其他语言中,如 Java 和 "
24052405"C#,日志对象通常是静态类属性。但在 Python 中是没有意义的,因为软件拆分的单位是模块(而不是类)。"
24062406
2407- #: ../../howto/logging-cookbook.rst:3924
2407+ #: ../../howto/logging-cookbook.rst:3947
24082408msgid ""
24092409"Adding handlers other than :class:`~logging.NullHandler` to a logger in a "
24102410"library"
24112411msgstr "为库中的日志记录器添加 :class:`~logging.NullHandler` 以外的处理句柄"
24122412
2413- #: ../../howto/logging-cookbook.rst:3926
2413+ #: ../../howto/logging-cookbook.rst:3949
24142414msgid ""
24152415"Configuring logging by adding handlers, formatters and filters is the "
24162416"responsibility of the application developer, not the library developer. If "
@@ -2421,11 +2421,11 @@ msgstr ""
24212421"来配置日志,这是应用程序开发人员的责任,而不是库开发人员该做的。如果正在维护一个库,请确保不要向任何日志对象添加 "
24222422":class:`~logging.NullHandler` 实例以外的 handler。"
24232423
2424- #: ../../howto/logging-cookbook.rst:3932
2424+ #: ../../howto/logging-cookbook.rst:3955
24252425msgid "Creating a lot of loggers"
24262426msgstr "创建大量的日志对象"
24272427
2428- #: ../../howto/logging-cookbook.rst:3934
2428+ #: ../../howto/logging-cookbook.rst:3957
24292429msgid ""
24302430"Loggers are singletons that are never freed during a script execution, and "
24312431"so creating lots of loggers will use up memory which can't then be freed. "
@@ -2439,14 +2439,14 @@ msgstr ""
24392439" :ref:`已有机制 <context-info>` "
24402440"将上下文信息传给自定义日志对象,并将创建的日志对象限制在应用程序内的指定区域(通常是模块,但偶尔会再精细些)使用。"
24412441
2442- #: ../../howto/logging-cookbook.rst:3945
2442+ #: ../../howto/logging-cookbook.rst:3968
24432443msgid "Other resources"
24442444msgstr "其他资源"
24452445
2446- #: ../../howto/logging-cookbook.rst:3958
2446+ #: ../../howto/logging-cookbook.rst:3981
24472447msgid ":ref:`Basic Tutorial <logging-basic-tutorial>`"
24482448msgstr ":ref:`基础教程 <logging-basic-tutorial>`"
24492449
2450- #: ../../howto/logging-cookbook.rst:3960
2450+ #: ../../howto/logging-cookbook.rst:3983
24512451msgid ":ref:`Advanced Tutorial <logging-advanced-tutorial>`"
24522452msgstr ":ref:`进阶教程 <logging-advanced-tutorial>`"
0 commit comments