MCPcopy Index your code
hub / github.com/python/cpython / shouldRollover

Method shouldRollover

Lib/logging/handlers.py:189–213  ·  view source on GitHub ↗

Determine if rollover should occur. Basically, see if the supplied record would cause the file to exceed the size limit we have.

(self, record)

Source from the content-addressed store, hash-verified

187 self.stream = self._open()
188
189 def shouldRollover(self, record):
190 """
191 Determine if rollover should occur.
192
193 Basically, see if the supplied record would cause the file to exceed
194 the size limit we have.
195 """
196 if self.stream is None: # delay was set...
197 self.stream = self._open()
198 if self.maxBytes > 0: # are we rolling over?
199 try:
200 pos = self.stream.tell()
201 except io.UnsupportedOperation:
202 # gh-143237: Never rollover a named pipe.
203 return False
204 if not pos:
205 # gh-116263: Never rollover an empty file
206 return False
207 msg = "%s\n" % self.format(record)
208 if pos + len(msg) >= self.maxBytes:
209 # See bpo-45401: Never rollover anything other than regular files
210 if os.path.exists(self.baseFilename) and not os.path.isfile(self.baseFilename):
211 return False
212 return True
213 return False
214
215class TimedRotatingFileHandler(BaseRotatingHandler):
216 """

Callers 6

test_should_rolloverMethod · 0.95
test_max_bytesMethod · 0.95
emitMethod · 0.45

Calls 5

_openMethod · 0.45
tellMethod · 0.45
formatMethod · 0.45
existsMethod · 0.45
isfileMethod · 0.45