def METHOD_NAME(self, data):
    """
    Write the data to either the current log or a new one,
    depending on the return of shouldRotate() and whether
    the new file can be opened.
    """
    if self.shouldRotate():
        self.rotate()
    if hasattr(self, "file"):
        r = self.file.METHOD_NAME(data)
        self.file.flush()
        return r