-
Notifications
You must be signed in to change notification settings - Fork 664
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
[generic_config_updater] Logging #1864
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,11 @@ | |
import yang as ly | ||
import copy | ||
import re | ||
from sonic_py_common import logger | ||
from enum import Enum | ||
|
||
YANG_DIR = "/usr/local/yang-models" | ||
SYSLOG_IDENTIFIER = "GenericConfigUpdater" | ||
|
||
class GenericConfigUpdaterError(Exception): | ||
pass | ||
|
@@ -691,3 +693,26 @@ def _get_model(self, model, name): | |
return submodel | ||
|
||
return None | ||
|
||
class GenericUpdaterLogger(logger.Logger): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
def __init__(self, title, verbose): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
super().__init__(SYSLOG_IDENTIFIER) | ||
self._title = title | ||
if verbose: | ||
self.set_min_log_priority_debug() | ||
|
||
def log(self, priority, msg, also_print_to_console=False): | ||
combined_msg = f"{self._title}: {msg}" | ||
super().log(priority, combined_msg, also_print_to_console) | ||
|
||
class LoggingSettings: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
def __init__(self): | ||
self.set_verbose(False) | ||
|
||
def set_verbose(self, verbose): | ||
self._verbose = verbose | ||
|
||
def getLogger(self, title): | ||
return GenericUpdaterLogger(title, self._verbose) | ||
|
||
loggingSettings = LoggingSettings() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
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.
Is this ident too long? The default will be process name such as
config
, is it good enough since you have addtitle
to diffentiate. #ClosedThere 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.
Here is how it look like:
I think it is OK, this way I can grep all syslogs associated with
GenericConfigUpdater
i.e.cat /var/log/syslog | grep GenericConfigUpdater
I think we will add more logs to other parts such config replace, rollback checkpoint and the applier.
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.
Also I don't think we should use
config
since this library might be used withREST
APIs like was requested in some of the earlier meetings with SONiC Community