import logging
import time

def initialize_logger(logger_name: str = 'ooi-annotations',
                      level: int | str = 'DEBUG') -> logging.Logger:
    """
    Set up a logger object for displaying verbose messages to console.

    :param logger_name: The unique logger name to use. Can be shared between modules
    :param level: The logging level to use. Default is DEBUG.
    :return: The configured logging.Logger object.
    """
    logger = logging.getLogger(logger_name)
    logger.propagate = False
    if not logger.handlers:
        logger.setLevel(logging.DEBUG)
        console = logging.StreamHandler()
        console.setLevel(level)

        # Set the logging format.
        dtfmt = '%Y-%m-%dT%H:%M:%S'
        strfmt = f'%(asctime)s.%(msecs)03dZ | %(name)-12s | %(levelname)-8s | %(message)s'
        fmt = logging.Formatter(strfmt, datefmt=dtfmt)
        fmt.converter = time.gmtime

        console.setFormatter(fmt)
        logger.addHandler(console)
    return logger