Skip to content
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

Set swsscommon logging level #178

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sonic_ax_impl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys

import swsssdk.util
from swsscommon import swsscommon

import ax_interface
import sonic_ax_impl
Expand Down Expand Up @@ -75,6 +76,10 @@ def install_fragments():
sonic_ax_impl.logger.setLevel(log_level)
ax_interface.logger.setLevel(log_level)
swsssdk.logger.setLevel(log_level_sdk)
# Note: swsscommon uses a fixed log level for simplicity
# TODO: improve it when log_level option is used
log_level_swsscommon = swsscommon.Logger.SWSS_ERROR
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be modified as below:
if args.get('log_level') is not None and args.get('log_level') == logging.INFO:
log_level_swsscommon = swsscommon.Logger.SWSS_INFO
if args.get('log_level') is not None and args.get('log_level') == logging.ERROR:
log_level_swsscommon = swsscommon.Logger.SWSS_ERROR
else:
log_level_swsscommon = swsscommon.Logger.SWSS_ERROR #Resolved

Copy link

@vaibhavhd vaibhavhd Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if args.get('log_level') is not None is not needed and we can directly check the value of args.get('log_level')

Qi, what are we achieving with this change (in order to fix sonic-net/sonic-buildimage#5992). Will the warnings start appearing as errors? #Resolved

Copy link

@vaibhavhd vaibhavhd Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the description of the PR be modified with some context? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings in swsscommon will still be warnings. Here I set the log_level higher to ERROR, so warning will disappear in syslog.


In reply to: 529841456 [](ancestors = 529841456)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


In reply to: 529842115 [](ancestors = 529842115)

swsscommon.Logger.getInstance().setMinPrio(log_level_swsscommon)

# inherit logging handlers in submodules
ax_interface.logger.handlers = sonic_ax_impl.logger.handlers
Expand Down