def __init__(self, logger_basename, debug_logging): """ :param debug_logging: each Client has a ``logger`` member. The logger is named ``gmusicapi.<client class><client number>`` and will propogate to the ``gmusicapi`` root logger. If this param is ``True``, handlers will be configured to send this client's log output to ``gmusicapi.log``, with warnings and above printed to the console. If ``False``, no handlers will be configured; users must create their own handlers. Completely ignoring logging is dangerous and not recommended. The Google Music protocol can change at any time; if something were to go wrong, the logs would be necessary for recovery. """ # this isn't correct if init is called more than once, so we log the # client name below to avoid confusion for people reading logs _Base.num_clients += 1 logger_name = "gmusicapi.%s%s" % (logger_basename, _Base.num_clients) self.logger = logging.getLogger(logger_name) if debug_logging: utils.configure_debug_log_handlers(self.logger) self.logger.info("initialized")
def __init__(self, logger_basename, debug_logging, validate, verify_ssl): """ :param debug_logging: each Client has a ``logger`` member. The logger is named ``gmusicapi.<client class><client number>`` and will propogate to the ``gmusicapi`` root logger. If this param is ``True``, handlers will be configured to send this client's debug log output to disk, with warnings and above printed to stderr. `Appdirs <https://pypi.python.org/pypi/appdirs>`__ ``user_log_dir`` is used by default. Users can run:: from gmusicapi.utils import utils print utils.log_filepath to see the exact location on their system. If ``False``, no handlers will be configured; users must create their own handlers. Completely ignoring logging is dangerous and not recommended. The Google Music protocol can change at any time; if something were to go wrong, the logs would be necessary for recovery. :param validate: if False, do not validate server responses against known schemas. This helps to catch protocol changes, but requires significant cpu work. This arg is stored as ``self.validate`` and can be safely modified at runtime. :param verify_ssl: if False, exceptions will not be raised if there are problems verifying SSL certificates. Be wary of using this option; it's almost always better to fix the machine's SSL configuration than to ignore errors. """ # this isn't correct if init is called more than once, so we log the # client name below to avoid confusion for people reading logs _Base.num_clients += 1 logger_name = "gmusicapi.%s%s" % (logger_basename, _Base.num_clients) self._cache = {} self.logger = logging.getLogger(logger_name) self.validate = validate self._verify_ssl = verify_ssl def setup_session(s): s.verify = self._verify_ssl self.session = self._session_class(rsession_setup=setup_session) if debug_logging: utils.configure_debug_log_handlers(self.logger) self.logger.info("initialized") self.logout()
def __init__(self, logger_basename, debug_logging): """ :param debug_logging: each Client has a ``logger`` member. The logger is named ``gmusicapi.<client class><client number>`` and will propogate to the ``gmusicapi`` root logger. If this param is ``True``, handlers will be configured to send this client's debug log output to disk, with warnings and above printed to stderr. `Appdirs <https://pypi.python.org/pypi/appdirs/1.2.0>`__ ``user_log_dir`` is used by default. Users can run:: from gmusicapi.utils import utils print utils.log_filepath to see the exact location on their system. If ``False``, no handlers will be configured; users must create their own handlers. Completely ignoring logging is dangerous and not recommended. The Google Music protocol can change at any time; if something were to go wrong, the logs would be necessary for recovery. """ # this isn't correct if init is called more than once, so we log the # client name below to avoid confusion for people reading logs _Base.num_clients += 1 logger_name = "gmusicapi.%s%s" % (logger_basename, _Base.num_clients) self.logger = logging.getLogger(logger_name) if debug_logging: utils.configure_debug_log_handlers(self.logger) self.logger.info("initialized")