@@ -18,7 +18,7 @@ msgid ""
1818msgstr ""
1919"Project-Id-Version : Python 3.7\n "
2020"Report-Msgid-Bugs-To : \n "
21- "POT-Creation-Date : 2019-08-08 08:00 +0000\n "
21+ "POT-Creation-Date : 2019-11-19 04:08 +0000\n "
2222"PO-Revision-Date : 2019-09-01 03:37+0000\n "
2323"
Last-Translator :
Shengjing Zhu <[email protected] >, 2019\n "
2424"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1534,3 +1534,116 @@ msgid ""
15341534"attach logging filters temporarily. Note that the above code works in Python"
15351535" 2 as well as Python 3."
15361536msgstr "当然,这里描述的方法可以被推广,例如临时附加日志记录过滤器。 请注意,上面的代码适用于Python 2以及Python 3。"
1537+
1538+ #: ../../howto/logging-cookbook.rst:2592
1539+ msgid "A CLI application starter template"
1540+ msgstr ""
1541+
1542+ #: ../../howto/logging-cookbook.rst:2594
1543+ msgid "Here's an example which shows how you can:"
1544+ msgstr ""
1545+
1546+ #: ../../howto/logging-cookbook.rst:2596
1547+ msgid "Use a logging level based on command-line arguments"
1548+ msgstr ""
1549+
1550+ #: ../../howto/logging-cookbook.rst:2597
1551+ msgid ""
1552+ "Dispatch to multiple subcommands in separate files, all logging at the same "
1553+ "level in a consistent way"
1554+ msgstr ""
1555+
1556+ #: ../../howto/logging-cookbook.rst:2599
1557+ msgid "Make use of simple, minimal configuration"
1558+ msgstr ""
1559+
1560+ #: ../../howto/logging-cookbook.rst:2601
1561+ msgid ""
1562+ "Suppose we have a command-line application whose job is to stop, start or "
1563+ "restart some services. This could be organised for the purposes of "
1564+ "illustration as a file ``app.py`` that is the main script for the "
1565+ "application, with individual commands implemented in ``start.py``, "
1566+ "``stop.py`` and ``restart.py``. Suppose further that we want to control the "
1567+ "verbosity of the application via a command-line argument, defaulting to "
1568+ "``logging.INFO``. Here's one way that ``app.py`` could be written::"
1569+ msgstr ""
1570+
1571+ #: ../../howto/logging-cookbook.rst:2650
1572+ msgid ""
1573+ "And the ``start``, ``stop`` and ``restart`` commands can be implemented in "
1574+ "separate modules, like so for starting::"
1575+ msgstr ""
1576+
1577+ #: ../../howto/logging-cookbook.rst:2663
1578+ msgid "and thus for stopping::"
1579+ msgstr ""
1580+
1581+ #: ../../howto/logging-cookbook.rst:2684
1582+ msgid "and similarly for restarting::"
1583+ msgstr ""
1584+
1585+ #: ../../howto/logging-cookbook.rst:2705
1586+ msgid ""
1587+ "If we run this application with the default log level, we get output like "
1588+ "this:"
1589+ msgstr ""
1590+
1591+ #: ../../howto/logging-cookbook.rst:2718
1592+ msgid ""
1593+ "The first word is the logging level, and the second word is the module or "
1594+ "package name of the place where the event was logged."
1595+ msgstr ""
1596+
1597+ #: ../../howto/logging-cookbook.rst:2721
1598+ msgid ""
1599+ "If we change the logging level, then we can change the information sent to "
1600+ "the log. For example, if we want more information:"
1601+ msgstr ""
1602+
1603+ #: ../../howto/logging-cookbook.rst:2738
1604+ msgid "And if we want less:"
1605+ msgstr ""
1606+
1607+ #: ../../howto/logging-cookbook.rst:2746
1608+ msgid ""
1609+ "In this case, the commands don't print anything to the console, since "
1610+ "nothing at ``WARNING`` level or above is logged by them."
1611+ msgstr ""
1612+
1613+ #: ../../howto/logging-cookbook.rst:2752
1614+ msgid "A Qt GUI for logging"
1615+ msgstr ""
1616+
1617+ #: ../../howto/logging-cookbook.rst:2754
1618+ msgid ""
1619+ "A question that comes up from time to time is about how to log to a GUI "
1620+ "application. The `Qt <https://www.qt.io/>`_ framework is a popular cross-"
1621+ "platform UI framework with Python bindings using `PySide2 "
1622+ "<https://pypi.org/project/PySide2/>`_ or `PyQt5 "
1623+ "<https://pypi.org/project/PyQt5/>`_ libraries."
1624+ msgstr ""
1625+
1626+ #: ../../howto/logging-cookbook.rst:2760
1627+ msgid ""
1628+ "The following example shows how to log to a Qt GUI. This introduces a simple"
1629+ " ``QtHandler`` class which takes a callable, which should be a slot in the "
1630+ "main thread that does GUI updates. A worker thread is also created to show "
1631+ "how you can log to the GUI from both the UI itself (via a button for manual "
1632+ "logging) as well as a worker thread doing work in the background (here, just"
1633+ " logging messages at random levels with random short delays in between)."
1634+ msgstr ""
1635+
1636+ #: ../../howto/logging-cookbook.rst:2767
1637+ msgid ""
1638+ "The worker thread is implemented using Qt's ``QThread`` class rather than "
1639+ "the :mod:`threading` module, as there are circumstances where one has to use"
1640+ " ``QThread``, which offers better integration with other ``Qt`` components."
1641+ msgstr ""
1642+
1643+ #: ../../howto/logging-cookbook.rst:2771
1644+ msgid ""
1645+ "The code should work with recent releases of either ``PySide2`` or "
1646+ "``PyQt5``. You should be able to adapt the approach to earlier versions of "
1647+ "Qt. Please refer to the comments in the code snippet for more detailed "
1648+ "information."
1649+ msgstr ""
0 commit comments