def __init__(self, core_services): self.__core = core_services self.__core.set_service("channel_manager", self) self.__channel_database = ChannelDatabase(self.__core)
class ChannelManager(object): """ The channel manager provides access to a number of channel related objects in the system: * The :class:`~channels.channel_database.ChannelDatabase`, through which the current :class:`~channels.channel.Channel` objects may be accessed. * The :class:`~channels.channel_publisher.ChannelPublisher`, which enables components of the system to register to receive channel updates. * The :class:`~channels.logging.logging_manager.LoggingManager`, which allows access to :class:`loggers <channels.logging.logger_base.LoggerBase>`. and the historical information that they can provide. It also provides shortcuts for the most common operations on these objects. """ def __init__(self, core_services): self.__core = core_services self.__core.set_service("channel_manager", self) self.__channel_database = ChannelDatabase(self.__core) def channel_database_get(self): """Return a reference to the :class:`~channels.channel_database.ChannelDatabase`. """ return self.__channel_database def channel_publisher_get(self): """ Return a reference to the :class:`~channels.channel_publisher.ChannelPublisher`. """ return self.__channel_database.channel_publisher_get() def channel_logging_manager_get(self): """Return a reference to the :class:`~channels.logging.logging_manager.LoggingManager`. """ return self.__channel_database.channel_logging_manager_get() def channel_logger_list(self): """Return a list of channel :class:`loggers <channels.logging.logger_base.LoggerBase>` """ logging_manager = self.__channel_database.channel_logging_manager_get() return logging_manager.instance_list() def channel_logger_get(self, logger_name): """Retrieve a specific :class:`logger <channels.logging.logger_base.LoggerBase>` instance Parameter: * `logger_name`: Name of the logger """ logging_manager = self.__channel_database.channel_logging_manager_get() return logging_manager.instance_get(logger_name) def channel_logger_exists(self, logger_name): """Returns whether the specified :class:`logger <channels.logging.logger_base.LoggerBase>` exists Parameter: * `logger_name`: Name of the logger """ logging_manager = self.__channel_database.channel_logging_manager_get() return logging_manager.instance_exists(logger_name)