-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support notice level log #19232
Support notice level log #19232
Conversation
/eazycla |
dbc6081
to
ce9d044
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi @prgeor would you please help to merge? |
@@ -4,13 +4,19 @@ | |||
import socket | |||
import sys | |||
|
|||
# customize python logging to support notice logger | |||
logging.NOTICE = logging.INFO + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Junchao-Mellanox how did you arrive at the formula?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python logging package support customizing log level. I read the source code of it and find that:
#---------------------------------------------------------------------------
#
# Default levels and level names, these can be replaced with any positive set
# of values having corresponding names. There is a pseudo-level, NOTSET, which
# is only really there as a lower limit for user-defined levels. Handlers and
# loggers are initialized with NOTSET so that they will log all messages, even
# at user-defined levels.
#
CRITICAL = 50
FATAL = CRITICAL
ERROR = 40
WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
NOTSET = 0
As you can see, there are 10 spare numbers between INFO and WARN, so I take INFO+1 as the NOTICE level.
Hi @qiluo-msft , could you please review this? |
7f7286f
Hi @qiluo-msft @prgeor , I added a test case and all checker passed. Could you please help merge this? |
#### Why I did it SysLogger does not support NOTICE level log. The PR is to support it. #### How I did it Add a new log level NOTICE to python logging package. #### How to verify it Manual test ``` Jun 3 03:09:44.353536 sonic NOTICE test[364076]: This is a notice ```
#### Why I did it SysLogger does not support NOTICE level log. The PR is to support it. #### How I did it Add a new log level NOTICE to python logging package. #### How to verify it Manual test ``` Jun 3 03:09:44.353536 sonic NOTICE test[364076]: This is a notice ```
Cherry-pick PR to 202405: #20010 |
#### Why I did it SysLogger does not support NOTICE level log. The PR is to support it. #### How I did it Add a new log level NOTICE to python logging package. #### How to verify it Manual test ``` Jun 3 03:09:44.353536 sonic NOTICE test[364076]: This is a notice ```
### **Issue** Fix the issue sonic-net/sonic-buildimage#21290 No info log found in syslog on 202405 image for caclmgrd ### **Work item tracking** - Microsoft ADO **(number only)**: 30611546 ### Why did it happen RP sonic-net/sonic-buildimage#17171, introduced a new Class SysLogger, DaemonBase will choose SysLogger by default PR sonic-net/sonic-buildimage#19232, it added noticed level and make it to be default level which suppresses INFO logs. `caclmgr.set_min_log_priority_info()` it sets min log priority to info, this function is in Logger class, SysLogger doesn't have this function. But DaemonBase still inherits Logger which implements set_min_log_priority_info, that's why even caclmgrd called this function, it didn't throw exception. But it didn't make INFO level effect in SysLogger which is actually used in caclmgrd Even change to use Logger by setting `use_syslogger=False`, it still doesn't work. The root cause is that it added a new instance for logger, `self.logger_instance`, any instance inherited from DaemonBase class can't change the debug level, the level they changed is their own instance, not the self.logger_instance's level. ### **How to fix** The solution here for caclmgrd is to choose logger.Logger class instead of DaemonBase. ### **How to verify it** Test it on 202405
### **Issue** Fix the issue sonic-net/sonic-buildimage#21290 No info log found in syslog on 202405 image for caclmgrd ### **Work item tracking** - Microsoft ADO **(number only)**: 30611546 ### Why did it happen RP sonic-net/sonic-buildimage#17171, introduced a new Class SysLogger, DaemonBase will choose SysLogger by default PR sonic-net/sonic-buildimage#19232, it added noticed level and make it to be default level which suppresses INFO logs. `caclmgr.set_min_log_priority_info()` it sets min log priority to info, this function is in Logger class, SysLogger doesn't have this function. But DaemonBase still inherits Logger which implements set_min_log_priority_info, that's why even caclmgrd called this function, it didn't throw exception. But it didn't make INFO level effect in SysLogger which is actually used in caclmgrd Even change to use Logger by setting `use_syslogger=False`, it still doesn't work. The root cause is that it added a new instance for logger, `self.logger_instance`, any instance inherited from DaemonBase class can't change the debug level, the level they changed is their own instance, not the self.logger_instance's level. ### **How to fix** The solution here for caclmgrd is to choose logger.Logger class instead of DaemonBase. ### **How to verify it** Test it on 202405
### **Issue** Fix the issue sonic-net/sonic-buildimage#21290 No info log found in syslog on 202405 image for caclmgrd ### **Work item tracking** - Microsoft ADO **(number only)**: 30611546 ### Why did it happen RP sonic-net/sonic-buildimage#17171, introduced a new Class SysLogger, DaemonBase will choose SysLogger by default PR sonic-net/sonic-buildimage#19232, it added noticed level and make it to be default level which suppresses INFO logs. `caclmgr.set_min_log_priority_info()` it sets min log priority to info, this function is in Logger class, SysLogger doesn't have this function. But DaemonBase still inherits Logger which implements set_min_log_priority_info, that's why even caclmgrd called this function, it didn't throw exception. But it didn't make INFO level effect in SysLogger which is actually used in caclmgrd Even change to use Logger by setting `use_syslogger=False`, it still doesn't work. The root cause is that it added a new instance for logger, `self.logger_instance`, any instance inherited from DaemonBase class can't change the debug level, the level they changed is their own instance, not the self.logger_instance's level. ### **How to fix** The solution here for caclmgrd is to choose logger.Logger class instead of DaemonBase. ### **How to verify it** Test it on 202405
### **Issue** Fix the issue sonic-net/sonic-buildimage#21290 No info log found in syslog on 202405 image for caclmgrd ### **Work item tracking** - Microsoft ADO **(number only)**: 30611546 ### Why did it happen RP sonic-net/sonic-buildimage#17171, introduced a new Class SysLogger, DaemonBase will choose SysLogger by default PR sonic-net/sonic-buildimage#19232, it added noticed level and make it to be default level which suppresses INFO logs. `caclmgr.set_min_log_priority_info()` it sets min log priority to info, this function is in Logger class, SysLogger doesn't have this function. But DaemonBase still inherits Logger which implements set_min_log_priority_info, that's why even caclmgrd called this function, it didn't throw exception. But it didn't make INFO level effect in SysLogger which is actually used in caclmgrd Even change to use Logger by setting `use_syslogger=False`, it still doesn't work. The root cause is that it added a new instance for logger, `self.logger_instance`, any instance inherited from DaemonBase class can't change the debug level, the level they changed is their own instance, not the self.logger_instance's level. ### **How to fix** The solution here for caclmgrd is to choose logger.Logger class instead of DaemonBase. ### **How to verify it** Test it on 202405
Why I did it
SysLogger does not support NOTICE level log. The PR is to support it.
Work item tracking
How I did it
Add a new log level NOTICE to python logging package.
How to verify it
Manual test
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)