def METHOD_NAME(comm=COMM_WORLD):
    """Set stream handlers for log messages.
    :kwarg comm: The communicator the handler should be collective
         over. Only rank-0 on that communicator will write to the log, other
         ranks will use a :class:`logging.NullHandler`.
    """
    def add_stream_handler(buffered=False):
        if comm is None or comm.rank == 0:
            if buffered:
                handler = BufferHandler(thetis_log_config.mem_buffer)
            else:
                handler = logging.StreamHandler()
            handler.setFormatter(logging.Formatter(fmt=fmt))
        else:
            handler = logging.NullHandler()
        logger.addHandler(handler)
    if thetis_log_config.mem_buffer is None:
        thetis_log_config.mem_buffer = io.StringIO()
    for name, fmt in logger_format.items():
        logger = logging.getLogger(name)
        for handler in logger.handlers:
            if isinstance(handler, logging.StreamHandler):
                logger.removeHandler(handler)
        add_stream_handler()
        add_stream_handler(buffered=True)