def log_exception():
    """
    Log exception with system info.

    Must be called in exception handler.
    """
    from compilertools._config import CONFIG
    if CONFIG.get('logging', True):
        from logging import getLogger
        import platform
        getLogger('compilertools').exception('\n'.join((
            'Compilertools: Exception when trying to enable optimization, Back to compatible mode.'
            , '  OS: %s' % platform.platform(), '  CPU: %s' % platform.
            processor(), '  Python: %s [%s]' % (platform.python_version(),
            platform.python_compiler()))))
