Skip to content

Commit 73848e0

Browse files
miss-islingtonandresdelfino
authored andcommitted
bpo-33943: Add references in the docs for logging.basicConfig (GH-7858) (GH-7899)
Adds references to info about file modes, `time.strftime()`, string formatting syntaxes, and logging levels. (cherry picked from commit a8ddf85) Co-authored-by: Andrés Delfino <[email protected]>
1 parent cef5da5 commit 73848e0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

Doc/library/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ are always available. They are listed here in alphabetical order.
957957
encoding. (For reading and writing raw bytes use binary mode and leave
958958
*encoding* unspecified.) The available modes are:
959959

960+
.. _filemodes:
961+
962+
.. index::
963+
pair: file; modes
964+
960965
========= ===============================================================
961966
Character Meaning
962967
========= ===============================================================

Doc/library/logging.rst

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,41 +1129,44 @@ functions.
11291129
+--------------+---------------------------------------------+
11301130
| Format | Description |
11311131
+==============+=============================================+
1132-
| ``filename`` | Specifies that a FileHandler be created, |
1132+
| *filename* | Specifies that a FileHandler be created, |
11331133
| | using the specified filename, rather than a |
11341134
| | StreamHandler. |
11351135
+--------------+---------------------------------------------+
1136-
| ``filemode`` | Specifies the mode to open the file, if |
1137-
| | filename is specified (if filemode is |
1138-
| | unspecified, it defaults to 'a'). |
1136+
| *filemode* | If *filename* is specified, open the file |
1137+
| | in this :ref:`mode <filemodes>`. Defaults |
1138+
| | to ``'a'``. |
11391139
+--------------+---------------------------------------------+
1140-
| ``format`` | Use the specified format string for the |
1140+
| *format* | Use the specified format string for the |
11411141
| | handler. |
11421142
+--------------+---------------------------------------------+
1143-
| ``datefmt`` | Use the specified date/time format. |
1143+
| *datefmt* | Use the specified date/time format, as |
1144+
| | accepted by :func:`time.strftime`. |
11441145
+--------------+---------------------------------------------+
1145-
| ``style`` | If ``format`` is specified, use this style |
1146-
| | for the format string. One of '%', '{' or |
1147-
| | '$' for %-formatting, :meth:`str.format` or |
1148-
| | :class:`string.Template` respectively, and |
1149-
| | defaulting to '%' if not specified. |
1146+
| *style* | If *format* is specified, use this style |
1147+
| | for the format string. One of ``'%'``, |
1148+
| | ``'{'`` or ``'$'`` for :ref:`printf-style |
1149+
| | <old-string-formatting>`, |
1150+
| | :meth:`str.format` or |
1151+
| | :class:`string.Template` respectively. |
1152+
| | Defaults to ``'%'``. |
11501153
+--------------+---------------------------------------------+
1151-
| ``level`` | Set the root logger level to the specified |
1152-
| | level. |
1154+
| *level* | Set the root logger level to the specified |
1155+
| | :ref:`level <levels>`. |
11531156
+--------------+---------------------------------------------+
1154-
| ``stream`` | Use the specified stream to initialize the |
1157+
| *stream* | Use the specified stream to initialize the |
11551158
| | StreamHandler. Note that this argument is |
1156-
| | incompatible with 'filename' - if both are |
1157-
| | present, a ``ValueError`` is raised. |
1159+
| | incompatible with *filename* - if both |
1160+
| | are present, a ``ValueError`` is raised. |
11581161
+--------------+---------------------------------------------+
1159-
| ``handlers`` | If specified, this should be an iterable of |
1162+
| *handlers* | If specified, this should be an iterable of |
11601163
| | already created handlers to add to the root |
11611164
| | logger. Any handlers which don't already |
11621165
| | have a formatter set will be assigned the |
11631166
| | default formatter created in this function. |
11641167
| | Note that this argument is incompatible |
1165-
| | with 'filename' or 'stream' - if both are |
1166-
| | present, a ``ValueError`` is raised. |
1168+
| | with *filename* or *stream* - if both |
1169+
| | are present, a ``ValueError`` is raised. |
11671170
+--------------+---------------------------------------------+
11681171

11691172
.. versionchanged:: 3.2

0 commit comments

Comments
 (0)