def METHOD_NAME(output_file=None):
    """Function collect dmesg and save in file.
    The dmesg operation is a privileged user task.
    This function needs sudo permissions enabled on the target host
    :param output_file: File use for save dmesg output if not provided it use
                        tmp file which located in system  /tmp path
    :type output_file: str
    :returns: file which contain dmesg
    :rtype: str
    """
    if output_file is None:
        _, output_file = tempfile.mkstemp(
            suffix=f".-{time.strftime('%Y-%m-%d:%H:%M:%S')}", dir=tempfile.gettempdir()
        )
    dmesg = process.system_output("dmesg", ignore_status=True, sudo=True).decode()
    genio.write_file(output_file, dmesg)
    if not os.path.isfile(output_file):
        raise DmesgError(f"{output_file} is not a valid file.")
    return output_file