Skip to content

Commit c5bf768

Browse files
[3.10] [doc] Update cookbook example and add information about queue types. (GH-94854) (GH-94872)
(cherry picked from commit dc54193)
1 parent 5d26f85 commit c5bf768

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ messages should not. Here's how you can achieve this::
219219
logging.basicConfig(level=logging.DEBUG,
220220
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
221221
datefmt='%m-%d %H:%M',
222-
filename='/temp/myapp.log',
222+
filename='/tmp/myapp.log',
223223
filemode='w')
224224
# define a Handler which writes INFO messages or higher to the sys.stderr
225225
console = logging.StreamHandler()
@@ -270,6 +270,11 @@ are sent to both destinations.
270270
This example uses console and file handlers, but you can use any number and
271271
combination of handlers you choose.
272272

273+
Note that the above choice of log filename ``/tmp/myapp.log`` implies use of a
274+
standard location for temporary files on POSIX systems. On Windows, you may need to
275+
choose a different directory name for the log - just ensure that the directory exists
276+
and that you have the permissions to create and update files in it.
277+
273278

274279
Configuration server example
275280
----------------------------

Doc/library/logging.handlers.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,8 @@ possible, while any potentially slow operations (such as sending an email via
10181018
have the task tracking API, which means that you can use
10191019
:class:`~queue.SimpleQueue` instances for *queue*.
10201020

1021+
.. note:: If you are using :mod:`multiprocessing`, you should avoid using
1022+
:class:`~queue.SimpleQueue` and instead use :class:`multiprocessing.Queue`.
10211023

10221024
.. method:: emit(record)
10231025

@@ -1091,6 +1093,9 @@ possible, while any potentially slow operations (such as sending an email via
10911093
task tracking API (though it's used if available), which means that you can
10921094
use :class:`~queue.SimpleQueue` instances for *queue*.
10931095

1096+
.. note:: If you are using :mod:`multiprocessing`, you should avoid using
1097+
:class:`~queue.SimpleQueue` and instead use :class:`multiprocessing.Queue`.
1098+
10941099
If ``respect_handler_level`` is ``True``, a handler's level is respected
10951100
(compared with the level for the message) when deciding whether to pass
10961101
messages to that handler; otherwise, the behaviour is as in previous Python

0 commit comments

Comments
 (0)