-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[sonic_daemon_base]Fix error: DaemonBase: object has no attribute 'syslog' #4034 #4039
Conversation
This should fix the issue, but I wonder if we should utilize the Logger class here, since it is defined in this file. In order to do so, we would need to pass the syslog_identifier to the DaemonBase constructor, however, so that it can instantiate the Logger class. How do you feel about taking this type of approach? |
Your approach is better except that it could introduce a bit more effort because current all derived classes of DaemonBase don't use the logger as a member of class but as a global variable in the file. We need to update the derived classes as well. |
I agree.
I don't quite understand what kind of impact making the change I suggested would have on the issue that was worked around by #3596. Could you please elaborate? |
Sorry, I don't express it clearly. I don't mean it will have impact. |
I see your point now. I guess I feel that since the Logger class is defined in the daemon_base.py file, it is intended to be either inherited by DaemonBase or used as a member of the class. If we want to use them separately (e.g., a class which derives from DaemonBase will create a global Logger instance), I think we should consider breaking Logger out into its own file in the future. We should consider creating a "sonic_tools" (or similar) Python package, which can house daemon_base.py, logger.py, minigraph.py, port_config.py, and all other Python libraries which are shared by mulitple SONiC Python programs. This, of course, is a bit of a large project, so I think for this fix, we should choose a solution which will work best with that future direction in mind. Since Python is object-oriented, I'd prefer to avoid global variables, if possible. What is there to be gained by adding a global Logger instance in DaemonBase versus adding a member variable? I think it makes subclassing DaemonBase easier to simply pass the log_identifier when construction the class, then the inheriting class automatically has a working Logger, rather than having to instantiate a separate global Logger variable. However, if a program which isn't a daemon just wants a logger, it can import the logger.py file and only take that class. As an alternative to the fix in #3596, maybe the platform API could take callback functions for logging instead of having global variables. That way, the platform API would call the callback functions of the running daemon rather than maintaining Logger state themselves. What do you think? |
Personally, I tend to agree with you except that we need to come up with a good way regarding how Logger is used in platform API. |
Agreed. Let's go ahead with this fix in the interim, and then discuss a good way to use Logger in the platform API. You can take this PR out of "Draft" state. |
Retest vs please |
Retest vsimage please |
Retest vs please |
Retest vsimage please |
retest vsimage please |
retest vs please |
retest vsimage please |
1 similar comment
retest vsimage please |
Retest vsimage please |
retest vsimage please |
- What I did
Fix error: DaemonBase: object has no attribute 'syslog' #4034
- How I did it
syslog is not a member of class DaemonBase, so remove the "self." in DaemonBase.
See issuecomment-575678314 for detail.
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)