def get_logger_files(logger):
    """
    Return file handlers of all currently active loggers.

    Result from this method will be used during daemonization process to close
    all open file descriptors but those belonging to given logger service.

    .. warning::

        This method is hacking internal structure of external module and might
        stop working, although the related interface has been stable for a long time.

    :param logging.Logger logger: Logger to be analyzed for open file descriptors.
    :return: List of open file descriptors used by logging service.
    :rtype: list
    """
    files = []
    for handler in logger.handlers:
        if hasattr(handler, 'stream') and hasattr(handler.stream, 'fileno'):
            files.append(handler.stream)
        if hasattr(handler, 'socket') and hasattr(handler.socket, 'fileno'):
            files.append(handler.socket)
    return files
