Skip to content

Commit

Permalink
utf-8 and json dump log
Browse files Browse the repository at this point in the history
  • Loading branch information
y12studio committed Sep 8, 2014
1 parent 14e6fab commit eb12afe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions node/tornadoloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,12 @@ def start_node(my_market_ip,
disable_open_browser=False):

logging.basicConfig(level=int(log_level),
format='%(asctime)s - %(name)s - \
%(levelname)s - %(message)s',
format=u'%(asctime)s - %(name)s - %(levelname)s - %(message)s',
filename=log_file)

logging._defaultFormatter = logging.Formatter(u'%(message)s')
locallogger = logging.getLogger('[%s] %s' % (market_id, 'root'))

handler = logging.handlers.RotatingFileHandler(log_file,
handler = logging.handlers.RotatingFileHandler(log_file, encoding='utf-8',
maxBytes=50,
backupCount=0)
locallogger.addHandler(handler)
Expand Down
4 changes: 2 additions & 2 deletions node/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def get_market_id(self):

def _ping(self, msg):

self.log.info('Pinged %s ' % pformat(msg))
self.log.info('Pinged %s ' % json.dumps(msg, ensure_ascii=False))
#
# pinger = CryptoPeerConnection(self, msg['uri'], msg['pubkey'], msg['senderGUID'])
# pinger.send_raw(json.dumps(
Expand Down Expand Up @@ -789,7 +789,7 @@ def _on_message(self, msg):
nickname = msg.get('senderNick')[:120]

self.dht.add_known_node((ip, port, guid, nickname))
self.log.info('ON MESSAGE %s' % msg)
self.log.info('ON MESSAGE %s' % json.dumps(msg, ensure_ascii=False))

self.dht.add_peer(self, uri, pubkey, guid, nickname)

Expand Down

0 comments on commit eb12afe

Please sign in to comment.