'This should be called when handling an unexpected exception. Will create a new log file containing the last 50
debug messages as well as the crash traceback.'

def crash_report(self):

    if (not self.unit_test):
        filename = os.path.join(self.config_base, datetime.now().strftime(u'crash_report.%Y.%m.%d.%H%M%S%f.log'))
        with codecs.open(filename, u'w', encoding=u'utf-8') as outfile:
            outfile.writelines(logger.debug_buffer)
            traceback.print_exc(file=outfile)
        log.critical(u'An    unexpected    crash    has    occurred.    Writing    crash    report    to    %s.    Please    verify    you    are    running    the    latest    version    of    flexget    by    using    "flexget    -V"    from    CLI    or    by    using    version_checker    plugin    at    http://flexget.com/wiki/Plugins/version_checker.    You    are    currently    using    version    %s', filename, get_current_flexget_version())
    log.debug(u'Traceback:', exc_info=True)
    return traceback.format_exc()
