jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/721331 )
Change subject: [cleanup] Remove deprecated RotatingFileHandler
......................................................................
[cleanup] Remove deprecated RotatingFileHandler
Change-Id: I581b0380e7117675fb50cf9e514dedce21ecb641
---
M pywikibot/bot.py
M pywikibot/tools/_logging.py
2 files changed, 1 insertion(+), 84 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 3197e60..5efe486 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -64,7 +64,7 @@
__all__ = (
'CRITICAL', 'ERROR', 'INFO', 'WARNING',
'DEBUG', 'INPUT', 'STDOUT',
'VERBOSE', 'critical', 'debug', 'error',
'exception', 'log', 'warning',
- 'output', 'stdout', 'LoggingFormatter',
'RotatingFileHandler',
+ 'output', 'stdout', 'LoggingFormatter',
'init_handlers', 'writelogheader',
'input', 'input_choice', 'input_yn',
'input_list_choice', 'ui',
'Option', 'StandardOption', 'NestedOption',
'IntegerOption',
@@ -176,7 +176,6 @@
deprecated,
deprecated_args,
issue_deprecation_warning,
- redirect_func,
remove_last_args,
suppress_warnings,
)
@@ -2330,10 +2329,6 @@
set_interface(config.userinterface)
-# Deprecate RotatingFileHandler
-RotatingFileHandler = redirect_func(logging.handlers.RotatingFileHandler,
- since='6.5.0')
-
# NOTE: (T286348)
# Do not use ModuleDeprecationWrapper with this module.
# pywikibot.bot.ui would be wrapped through the ModuleDeprecationWrapper
diff --git a/pywikibot/tools/_logging.py b/pywikibot/tools/_logging.py
index 830b8d9..682f3e2 100644
--- a/pywikibot/tools/_logging.py
+++ b/pywikibot/tools/_logging.py
@@ -5,76 +5,6 @@
# Distributed under the terms of the MIT license.
#
import logging
-import os
-
-from pywikibot.tools import ModuleDeprecationWrapper
-
-
-class _RotatingFileHandler(logging.handlers.RotatingFileHandler):
-
- """DEPRECATED Modified RotatingFileHandler.
-
- Use namer instead. See:
-
https://docs.python.org/3/howto/logging-cookbook.html#cookbook-rotator-namer
- """
-
- def doRollover(self):
- """Modified naming system for logging files.
-
- Overwrites the default Rollover renaming by inserting the count
- number between file name root and extension. If backupCount is
- >= 1, the system will successively create new files with the
- same pathname as the base file, but with inserting ".1",
".2"
- etc. in front of the filename suffix. For example, with a
- backupCount of 5 and a base file name of "app.log", you would
- get "app.log", "app.1.log", "app.2.log", ...
through to
- "app.5.log". The file being written to is always "app.log" -
- when it gets filled up, it is closed and renamed to "app.1.log",
- and if files "app.1.log", "app.2.log" etc. already exist,
then
- they are renamed to "app.2.log", "app.3.log" etc.
respectively.
-
- If backupCount is == -1 do not rotate but create new numbered
- filenames. The newest file has the highest number except some
- older numbered files where deleted and the bot was restarted.
- In this case the ordering starts from the lowest available
- (unused) number.
- """
- fmt = '{}.{}{}'
-
- if self.stream:
- self.stream.close()
- self.stream = None
-
- root, ext = os.path.splitext(self.baseFilename)
-
- if self.backupCount > 0:
- for i in range(self.backupCount - 1, 0, -1):
- sfn = self.rotation_filename(fmt.format(root, i, ext))
- dfn = self.rotation_filename(fmt.format(root, i + 1, ext))
- if os.path.exists(sfn):
- if os.path.exists(dfn):
- os.remove(dfn)
- os.rename(sfn, dfn)
- dfn = self.rotation_filename(fmt.format(root, 1, ext))
- if os.path.exists(dfn):
- os.remove(dfn)
- self.rotate(self.baseFilename, dfn)
-
- elif self.backupCount == -1:
- if not hasattr(self, '_last_no'):
- self._last_no = 1
- while True:
- fn = self.rotation_filename(fmt.format(root, self._last_no,
- ext))
- self._last_no += 1
- if not os.path.exists(fn):
- break
- self.rotate(self.baseFilename, fn)
-
- self.mode = 'w'
-
- if not self.delay:
- self.stream = self._open()
class LoggingFormatter(logging.Formatter):
@@ -98,11 +28,3 @@
record.args = (msg,)
return super().format(record).rstrip()
-
-
-wrapper = ModuleDeprecationWrapper(__name__)
-wrapper.add_deprecated_attr(
- 'RotatingFileHandler', _RotatingFileHandler,
- replacement_name=('logging.handlers.RotatingFileHandler '
- 'with your own namer'),
- since='6.5.0')
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/721331
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I581b0380e7117675fb50cf9e514dedce21ecb641
Gerrit-Change-Number: 721331
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged