import ctypes


def get_log(handle, log_fn):
    """Get logs from OpenGL.

    :param handle: Handle for the associated object.
    :param func log_fn: Function to call to get logs.
    :returns: str
    """
    c_buffer = ctypes.create_string_buffer(4096)
    c_buffer_pointer = ctypes.cast(ctypes.pointer(c_buffer),
                                   ctypes.POINTER(ctypes.c_char))
    c_written = ctypes.c_int()
    log_fn(handle, 4096, ctypes.pointer(c_written), c_buffer_pointer)
    return c_buffer.value