Skip to content

Commit 4d24357

Browse files
committed
gh-116267: Do not check record size in RotatingFileHandler to avoid formatting twice
1 parent eb22e2b commit 4d24357

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Lib/logging/handlers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,19 @@ def doRollover(self):
180180
if not self.delay:
181181
self.stream = self._open()
182182

183-
def shouldRollover(self, record):
183+
def shouldRollover(self, _):
184184
"""
185-
Determine if rollover should occur.
186-
187-
Basically, see if the supplied record would cause the file to exceed
188-
the size limit we have.
185+
Determine if the file has exceeded the size limit we have,
186+
and therefore we should roll over.
189187
"""
190188
# See bpo-45401: Never rollover anything other than regular files
191189
if os.path.exists(self.baseFilename) and not os.path.isfile(self.baseFilename):
192190
return False
193191
if self.stream is None: # delay was set...
194192
self.stream = self._open()
195193
if self.maxBytes > 0: # are we rolling over?
196-
msg = "%s\n" % self.format(record)
197194
self.stream.seek(0, 2) #due to non-posix-compliant Windows feature
198-
if self.stream.tell() + len(msg) >= self.maxBytes:
195+
if self.stream.tell() >= self.maxBytes:
199196
return True
200197
return False
201198

0 commit comments

Comments
 (0)