'Rotates our log file and appends some number of lines from
the previous log to the start of the new one.'

def rotate(self):

    append_tail = (self.num_lines_to_append > 0)
    if (not append_tail):
        logfile.LogFile.rotate(self)
        return
    lines = tail_log_file(self.path, 0, self.num_lines_to_append)
    logfile.LogFile.rotate(self)
    for line in lines:
        self.write(line)
