Skip to content

[SAI-PTF] API Logger - reformat dict in return value #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

richardyu-ms
Copy link
Collaborator

Why
Base on some requirement, when logging the return value is a dict, need return the value for each key as a string.

For example, returning this.

 "[{
'client': <sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>,
'port_oid': 4294967303,
'hw_lane_list': sai_thrift_object_list_t(count=100, idlist=[1,2,34])
}]"

it returned as (see the ' around the value too below)

"[{
'client': '<sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>', 'port_oid': '4294967303',
'hw_lane_list': 'sai_thrift_object_list_t(count=100, idlist=[1,2,34])' }]"

How
Convert the dict value to string

Test:
Unit test and DUT test

Signed-off-by: richardyu-ms [email protected]

Why
Base on some requirement, when logging the return value is a dict, need return the value for each key as a string.

For example,  returning this.
```
 "[{
'client': <sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>,
'port_oid': 4294967303,
'hw_lane_list': sai_thrift_object_list_t(count=100, idlist=[1,2,34])
}]"
```
 it returned as (see the ' around the value too below)
 ```
"[{
'client': '<sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>',
'port_oid': '4294967303',
'hw_lane_list': 'sai_thrift_object_list_t(count=100, idlist=[1,2,34])'
}]"
```

How
Convert the dict value to string

Test:
Unit test and DUT test

Signed-off-by: richardyu-ms <[email protected]>
@richardyu-ms richardyu-ms merged commit 1ba774b into opencomputeproject:v1.7 Dec 22, 2022
@richardyu-ms richardyu-ms deleted the api_logger_str_val branch December 22, 2022 05:05
richardyu-ms added a commit to richardyu-ms/sonic-sairedis that referenced this pull request Dec 22, 2022
richardyu-ms added a commit to sonic-net/sonic-sairedis that referenced this pull request Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants