From b2170d69eae918127a359dbb1bdd3347442e63db Mon Sep 17 00:00:00 2001 From: mLewisLogic Date: Thu, 1 Dec 2011 17:56:47 -0500 Subject: [PATCH] handle unicode logging --- hoover/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hoover/utils.py b/hoover/utils.py index bdf87b1..441f42f 100644 --- a/hoover/utils.py +++ b/hoover/utils.py @@ -22,8 +22,14 @@ def newfunc(*args, **kwargs): return wraps(func)(newfunc) -def post_to_endpoint(endpoint, message): +def post_to_endpoint(endpoint, message, encoding='utf-8'): h = Http() + # If unicode, try to encode + if isinstance(message, unicode): + try: + message = message.encode(encoding) + except UnicodeEncodeError: + pass h.request(endpoint, 'POST', message) async_post_to_endpoint = async(post_to_endpoint)