Skip to content

Commit 9d78ced

Browse files
authored
[SAI-PTF] API Logger - reformat arg values (#1695)
Why Base on some requirement, when logging the arg values, need return the value for each key as a string. For example, returning this. ``` sai_adapter_invoke func:[sai_thrift_create_route_entry] args: [{'client': <sai_thrift.sai_rpc.Client object at 0x7f9e07154438>, 'route_entry': sai_thrift_route_entry_t(switch_id=None, vr_id=12884901888, destination=sai_thrift_ip_prefix_t(addr_family=1, addr=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'), mask=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'))), 'packet_action': 0}] ``` Turn into ``` sai_adapter_invoke func:[sai_thrift_create_route_entry] args: [{'client': '<sai_thrift.sai_rpc.Client object at 0x7f9e07154438>', 'route_entry': 'sai_thrift_route_entry_t(switch_id=None, vr_id=12884901888, destination=sai_thrift_ip_prefix_t(addr_family=1, addr=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'), mask=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000')))', 'packet_action': '0'}] ``` How Convert the dict value to string Test: Unit test and DUT test Signed-off-by: richardyu-ms <[email protected]> Signed-off-by: richardyu-ms <[email protected]>
1 parent 9c82b01 commit 9d78ced

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

meta/templates/sai_adapter_utils.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def invocation_logger(func):
232232

233233
args_dict = dict(zip(args_name, args))
234234
args_dict.update(kwargs)
235+
args_dict = { key:str(value) for (key,value) in args_dict.items()}
235236
logging.info("sai_adapter_invoke func:[{}] args: [{}]".format(func.__name__, args_dict))
236237

237238
args_values = args_dict.values()

0 commit comments

Comments
 (0)