lib/ofctl_utils: Log the datapath sent to

If a controller has multiple switches connected it is useful to be able
to distinguish which datapath the msg is being sent to.

Signed-off-by: Jason Kölker <jason@koelker.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Jason Kölker 2016-06-28 18:18:56 +00:00 committed by FUJITA Tomonori
parent b0ab4f1602
commit 8b038a492e
1 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import logging
import netaddr
import six
from ryu.lib import dpid
from ryu.lib import hub
@ -229,7 +230,12 @@ def send_msg(dp, msg, logger=None):
if msg.xid is None:
dp.set_xid(msg)
get_logger(logger).debug('Sending message with xid(%x): %s', msg.xid, msg)
log = get_logger(logger)
# NOTE(jkoelker) Prevent unnecessary string formating by including the
# format rules in the log_msg
log_msg = ('Sending message with xid(%x) to '
'datapath(' + dpid._DPID_FMT + '): %s')
log.debug(log_msg, msg.xid, dp.id, msg)
dp.send_msg(msg)