-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-37111: Add 'encoding' and 'errors' parameters to logging.basicCon… #14008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,18 +89,22 @@ sends logging output to a disk file. It inherits the output functionality from | |
| :class:`StreamHandler`. | ||
|
|
||
|
|
||
| .. class:: FileHandler(filename, mode='a', encoding=None, delay=False) | ||
| .. class:: FileHandler(filename, mode='a', encoding=None, delay=False, errors=None) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps make it keyword only (add |
||
|
|
||
| Returns a new instance of the :class:`FileHandler` class. The specified file is | ||
| opened and used as the stream for logging. If *mode* is not specified, | ||
| :const:`'a'` is used. If *encoding* is not ``None``, it is used to open the file | ||
| with that encoding. If *delay* is true, then file opening is deferred until the | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. If | ||
| *errors* is specified, it's used to determine how encoding errors are handled. | ||
|
|
||
| .. versionchanged:: 3.6 | ||
| As well as string values, :class:`~pathlib.Path` objects are also accepted | ||
| for the *filename* argument. | ||
|
|
||
| .. versionchanged:: 3.9 | ||
| The *errors* parameter was added. | ||
|
|
||
| .. method:: close() | ||
|
|
||
| Closes the file. | ||
|
|
@@ -168,18 +172,22 @@ exclusive locks - and so there is no need for such a handler. Furthermore, | |
| for this value. | ||
|
|
||
|
|
||
| .. class:: WatchedFileHandler(filename, mode='a', encoding=None, delay=False) | ||
| .. class:: WatchedFileHandler(filename, mode='a', encoding=None, delay=False, errors=None) | ||
|
|
||
| Returns a new instance of the :class:`WatchedFileHandler` class. The specified | ||
| file is opened and used as the stream for logging. If *mode* is not specified, | ||
| :const:`'a'` is used. If *encoding* is not ``None``, it is used to open the file | ||
| with that encoding. If *delay* is true, then file opening is deferred until the | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. If | ||
| *errors* is provided, it determines how encoding errors are handled. | ||
|
|
||
| .. versionchanged:: 3.6 | ||
| As well as string values, :class:`~pathlib.Path` objects are also accepted | ||
| for the *filename* argument. | ||
|
|
||
| .. versionchanged:: 3.9 | ||
| The *errors* parameter was added. | ||
|
|
||
| .. method:: reopenIfNeeded() | ||
|
|
||
| Checks to see if the file has changed. If it has, the existing stream is | ||
|
|
@@ -205,7 +213,7 @@ module, is the base class for the rotating file handlers, | |
| not need to instantiate this class, but it has attributes and methods you may | ||
| need to override. | ||
|
|
||
| .. class:: BaseRotatingHandler(filename, mode, encoding=None, delay=False) | ||
| .. class:: BaseRotatingHandler(filename, mode, encoding=None, delay=False, errors=None) | ||
|
|
||
| The parameters are as for :class:`FileHandler`. The attributes are: | ||
|
|
||
|
|
@@ -284,13 +292,14 @@ The :class:`RotatingFileHandler` class, located in the :mod:`logging.handlers` | |
| module, supports rotation of disk log files. | ||
|
|
||
|
|
||
| .. class:: RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False) | ||
| .. class:: RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False, errors=None) | ||
|
|
||
| Returns a new instance of the :class:`RotatingFileHandler` class. The specified | ||
| file is opened and used as the stream for logging. If *mode* is not specified, | ||
| ``'a'`` is used. If *encoding* is not ``None``, it is used to open the file | ||
| with that encoding. If *delay* is true, then file opening is deferred until the | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. | ||
| first call to :meth:`emit`. By default, the file grows indefinitely. If | ||
| *errors* is provided, it determines how encoding errors are handled. | ||
|
|
||
| You can use the *maxBytes* and *backupCount* values to allow the file to | ||
| :dfn:`rollover` at a predetermined size. When the size is about to be exceeded, | ||
|
|
@@ -311,6 +320,9 @@ module, supports rotation of disk log files. | |
| As well as string values, :class:`~pathlib.Path` objects are also accepted | ||
| for the *filename* argument. | ||
|
|
||
| .. versionchanged:: 3.9 | ||
| The *errors* parameter was added. | ||
|
|
||
| .. method:: doRollover() | ||
|
|
||
| Does a rollover, as described above. | ||
|
|
@@ -331,7 +343,7 @@ The :class:`TimedRotatingFileHandler` class, located in the | |
| timed intervals. | ||
|
|
||
|
|
||
| .. class:: TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, atTime=None) | ||
| .. class:: TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, atTime=None, errors=None) | ||
|
|
||
| Returns a new instance of the :class:`TimedRotatingFileHandler` class. The | ||
| specified file is opened and used as the stream for logging. On rotating it also | ||
|
|
@@ -391,6 +403,9 @@ timed intervals. | |
| rollover, and subsequent rollovers would be calculated via the normal | ||
| interval calculation. | ||
|
|
||
| If *errors* is specified, it's used to determine how encoding errors are | ||
| handled. | ||
|
|
||
| .. note:: Calculation of the initial rollover time is done when the handler | ||
| is initialised. Calculation of subsequent rollover times is done only | ||
| when rollover occurs, and rollover occurs only when emitting output. If | ||
|
|
@@ -411,6 +426,9 @@ timed intervals. | |
| As well as string values, :class:`~pathlib.Path` objects are also accepted | ||
| for the *filename* argument. | ||
|
|
||
| .. versionchanged:: 3.9 | ||
| The *errors* parameter was added. | ||
|
|
||
| .. method:: doRollover() | ||
|
|
||
| Does a rollover, as described above. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.