Przeglądaj źródła

docs: made the logging docs clearer

Mikael Koli 4 lat temu
rodzic
commit
71a26f3c29
1 zmienionych plików z 15 dodań i 20 usunięć
  1. 15 20
      docs/extensions/logging.rst

+ 15 - 20
docs/extensions/logging.rst

@@ -29,7 +29,7 @@ The mechanics are simple and very similar between these two handlers.
 EmailHandler
 ------------
 
-To send one log record per email, use :class:`.EmailHandler`.
+To send one log record per email, use :class:`.EmailHandler`:
 
 .. code-block:: python
 
@@ -40,11 +40,15 @@ To send one log record per email, use :class:`.EmailHandler`.
         host="localhost",
         port=0,
         subject="A log record",
+        sender="no-reply@example.com",
         receivers=["me@example.com"],
     )
     logger = logging.getLogger(__name__)
     logger.addHandler(hdlr)
 
+    # To use:
+    logger.warning("A warning happened")
+
 .. note::
 
     You may pass the :class:`.EmailSender` 
@@ -66,13 +70,6 @@ To send one log record per email, use :class:`.EmailHandler`.
     receivers, text, html, etc.) are set as attributes to 
     this copied instance.
 
-
-To use this, simply:
-
-.. code-block:: python
-
-    logger.warning("A warning happened")
-
 You may also template the subject and the bodies:
 
 .. code-block:: python
@@ -130,11 +127,21 @@ To send multiple log records with one email, use :class:`.MultiEmailHandler`:
         host="localhost",
         port=0,
         subject="log records",
+        sender="no-reply@example.com",
         receivers=["me@example.com"],
     )
     logger = logging.getLogger(__name__)
     logger.addHandler(hdlr)
 
+    # To use:
+    logger.warning("A warning happened")
+    logger.warning("Another warning happened")
+    # (Now an email should have been sent)
+
+    # You may also manually flush
+    logger.warning("A warning happened")
+    hdlr.flush()
+
 .. note::
 
     You may pass the :class:`.EmailSender` 
@@ -156,18 +163,6 @@ To send multiple log records with one email, use :class:`.MultiEmailHandler`:
     receivers, text, html, etc.) are set as attributes to 
     this copied instance.
 
-To use this, simply:
-
-.. code-block:: python
-
-    logger.warning("A warning happened")
-    logger.warning("A warning happened")
-    # Should have now sent an email
-
-    # Or manually flush
-    logger.warning("A warning happened")
-    hdlr.flush()
-
 You may also template the subject and the bodies:
 
 .. code-block:: python