def enablePushover(self, userkey, APIkey): self.pushover = namedtuple('Pushover', 'notifier APIkey userkey')( get_notifier('pushover'), APIkey, userkey, ) defaults = { 'user': userkey, 'token': APIkey, } handler = NotificationHandler('pushover', defaults=defaults) handler.setLevel(logging.ERROR) handler.setFormatter(logging.Formatter('%(asctime)s - %(message)s')) log = logging.getLogger() log.addHandler(handler) self.notify('Pushover enabled for logging')
def enableTelegram(self, chatID, token): self.telegram = namedtuple('Telegram', 'notifier chatID token')( get_notifier('telegram'), chatID, token, ) defaults = { 'chat_id': chatID, 'token': token, } handler = NotificationHandler('telegram', defaults=defaults) handler.setLevel(logging.ERROR) handler.setFormatter(logging.Formatter('%(asctime)s - %(message)s')) log = logging.getLogger() log.addHandler(handler) self.notify('Telegram enabled for logging')
def return_handler(provider_name, logging_level, data=None, **kwargs): caplog.set_level(logging.INFO) hdlr = NotificationHandler(provider_name, data, **kwargs) hdlr.setLevel(logging_level) return hdlr