From cf314c7d34294681ff196e279496f6e67d76dbd8 Mon Sep 17 00:00:00 2001 From: Gobberwart Date: Wed, 7 Sep 2016 11:01:56 +1000 Subject: [PATCH 1/3] Fix unicode error in logging handlers --- pokemongo_bot/event_handlers/colored_logging_handler.py | 5 ++++- pokemongo_bot/event_handlers/logging_handler.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/event_handlers/colored_logging_handler.py b/pokemongo_bot/event_handlers/colored_logging_handler.py index 28e9057a57..1e9edc1510 100644 --- a/pokemongo_bot/event_handlers/colored_logging_handler.py +++ b/pokemongo_bot/event_handlers/colored_logging_handler.py @@ -136,4 +136,7 @@ def handle_event(self, event, sender, level, formatted_msg, data): formatted_msg = '[{}] {}'.format(event, formatted_msg) logger = logging.getLogger(type(sender).__name__) - getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) + try: + getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) + except UnicodeDecodeError: + getattr(logger, level)(formatted_msg) diff --git a/pokemongo_bot/event_handlers/logging_handler.py b/pokemongo_bot/event_handlers/logging_handler.py index 44cdd37b81..bd857d5e3e 100644 --- a/pokemongo_bot/event_handlers/logging_handler.py +++ b/pokemongo_bot/event_handlers/logging_handler.py @@ -20,4 +20,7 @@ def handle_event(self, event, sender, level, formatted_msg, data): formatted_msg = '[{}] {}'.format(event, formatted_msg) logger = logging.getLogger(type(sender).__name__) - getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) + try: + getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) + except UnicodeDecodeError: + getattr(logger, level)(formatted_msg) From ba1315db704514054c1f2c3f1c60578b15a5a243 Mon Sep 17 00:00:00 2001 From: Gobberwart Date: Wed, 7 Sep 2016 11:13:29 +1000 Subject: [PATCH 2/3] Removed extraneous comma --- pokecli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokecli.py b/pokecli.py index 2a20b75f5d..cd88d2ccd0 100644 --- a/pokecli.py +++ b/pokecli.py @@ -253,7 +253,7 @@ def get_commit_hash(): 'cached_fort', sender=bot, level='debug', - formatted='Forts cached.', + formatted='Forts cached.' ) except IOError as e: bot.event_manager.emit( From f27a3c237b563060c88eb613ea6831a07d791109 Mon Sep 17 00:00:00 2001 From: Gobberwart Date: Wed, 7 Sep 2016 12:06:15 +1000 Subject: [PATCH 3/3] Removed logging_handler bandaid --- pokemongo_bot/event_handlers/colored_logging_handler.py | 5 +---- pokemongo_bot/event_handlers/logging_handler.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pokemongo_bot/event_handlers/colored_logging_handler.py b/pokemongo_bot/event_handlers/colored_logging_handler.py index 1e9edc1510..28e9057a57 100644 --- a/pokemongo_bot/event_handlers/colored_logging_handler.py +++ b/pokemongo_bot/event_handlers/colored_logging_handler.py @@ -136,7 +136,4 @@ def handle_event(self, event, sender, level, formatted_msg, data): formatted_msg = '[{}] {}'.format(event, formatted_msg) logger = logging.getLogger(type(sender).__name__) - try: - getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) - except UnicodeDecodeError: - getattr(logger, level)(formatted_msg) + getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) diff --git a/pokemongo_bot/event_handlers/logging_handler.py b/pokemongo_bot/event_handlers/logging_handler.py index bd857d5e3e..44cdd37b81 100644 --- a/pokemongo_bot/event_handlers/logging_handler.py +++ b/pokemongo_bot/event_handlers/logging_handler.py @@ -20,7 +20,4 @@ def handle_event(self, event, sender, level, formatted_msg, data): formatted_msg = '[{}] {}'.format(event, formatted_msg) logger = logging.getLogger(type(sender).__name__) - try: - getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8")) - except UnicodeDecodeError: - getattr(logger, level)(formatted_msg) + getattr(logger, level)(formatted_msg.encode(sys.stdout.encoding, "replace").decode("utf-8"))