implement utils.print_exception()

Previously we used logging.error(e) and traceback.print_exc()
to output error stack trace. The problem is, we want to
output the stack trace only when verbose > 0. The if statement
scattered around the code. So we replaced them with the new
utils.print_exception() call.
This commit is contained in:
clowwindy 2015-02-10 17:16:24 +08:00
parent 48ddc1714b
commit cb7062e1c1
8 changed files with 32 additions and 29 deletions

View file

@ -25,7 +25,7 @@ import struct
import re
import logging
from shadowsocks import common, lru_cache, eventloop
from shadowsocks import common, lru_cache, eventloop, utils
CACHE_SWEEP_INTERVAL = 30
@ -221,9 +221,7 @@ def parse_response(data):
response.answers.append((an[1], an[2], an[3]))
return response
except Exception as e:
import traceback
traceback.print_exc()
logging.error(e)
utils.print_exception(e)
return None