mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
initial work on log once option
This commit is contained in:
parent
f9c9787251
commit
468b26e918
2 changed files with 11 additions and 0 deletions
|
@ -157,6 +157,9 @@ LOGGING_LOGGER_CLASS = logging.getLoggerClass()
|
|||
|
||||
|
||||
class SaltLoggingClass(LOGGING_LOGGER_CLASS, metaclass=LoggingMixinMeta):
|
||||
|
||||
ONCECACHE = set()
|
||||
|
||||
def __new__(cls, *args):
|
||||
"""
|
||||
We override `__new__` in our logging logger class in order to provide
|
||||
|
@ -233,10 +236,16 @@ class SaltLoggingClass(LOGGING_LOGGER_CLASS, metaclass=LoggingMixinMeta):
|
|||
stack_info=False,
|
||||
stacklevel=1,
|
||||
exc_info_on_loglevel=None,
|
||||
once=False,
|
||||
):
|
||||
if extra is None:
|
||||
extra = {}
|
||||
|
||||
if once:
|
||||
if str(args) in self.ONCECACHE:
|
||||
return
|
||||
self.ONCECACHE.add(str(args))
|
||||
|
||||
# pylint: disable=no-member
|
||||
current_jid = RequestContext.current.get("data", {}).get("jid", None)
|
||||
log_fmt_jid = RequestContext.current.get("opts", {}).get("log_fmt_jid", None)
|
||||
|
@ -265,6 +274,7 @@ class SaltLoggingClass(LOGGING_LOGGER_CLASS, metaclass=LoggingMixinMeta):
|
|||
exc_info_on_loglevel
|
||||
)
|
||||
)
|
||||
# XXX: extra is never None
|
||||
if extra is None:
|
||||
extra = {"exc_info_on_loglevel": exc_info_on_loglevel}
|
||||
else:
|
||||
|
|
|
@ -1275,6 +1275,7 @@ def _virtual(osdata):
|
|||
"cannot execute it. Grains output might not be "
|
||||
"accurate.",
|
||||
command,
|
||||
once=True,
|
||||
)
|
||||
return grains
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue