human
Complete the below
def log_file(msg, filename='game.log'):

    ''''Arbitrary file logger using threads.
    Args:
    msg (str): String to append to logfile.
    filename (str, optional): Defaults to \'game.log\'. All logs
    will appear in the logs directory and log entries will start
    on new lines following datetime info.'
    '''
assistant
#Here is the Python code you requested.
    def callback(filehandle, msg):
        'Writing    to    file    and    flushing    result'
        msg = ('\n%s    [-]    %s' % (timeformat(), msg.strip()))
        filehandle.write(msg)
        filehandle.flush()
    def errback(failure):
        'Catching    errors    to    normal    log'
        log_trace()
    filehandle = _open_log_file(filename)
    if filehandle:
        deferToThread(callback, filehandle, msg).addErrback(errback)