From b5a92a5fc3e94ce937f03ddcc83a248feb153778 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 19 Nov 2015 13:07:30 -0700 Subject: [PATCH] Pack log handlers with grains and mods Refs #28999 --- salt/loader.py | 3 ++- salt/log/handlers/sentry_mod.py | 4 ---- salt/log/setup.py | 5 ++++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 1c18d0ab04..56efe9177a 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -493,7 +493,7 @@ def search(opts, returners, whitelist=None): ) -def log_handlers(opts): +def log_handlers(opts, functions=None, grains=None): ''' Returns the custom logging handler modules @@ -509,6 +509,7 @@ def log_handlers(opts): ), opts, tag='log_handlers', + pack={'__salt__': functions, '__grains__': grains} ) return FilterDictWrapper(ret, '.setup_handlers') diff --git a/salt/log/handlers/sentry_mod.py b/salt/log/handlers/sentry_mod.py index f729f4a05d..fb53146c3a 100644 --- a/salt/log/handlers/sentry_mod.py +++ b/salt/log/handlers/sentry_mod.py @@ -93,8 +93,6 @@ except ImportError: HAS_RAVEN = False log = logging.getLogger(__name__) -__grains__ = {} -__salt__ = {} # Define the module's virtual name __virtualname__ = 'sentry' @@ -102,8 +100,6 @@ __virtualname__ = 'sentry' def __virtual__(): if HAS_RAVEN is True: - __grains__ = salt.loader.grains(__opts__) - __salt__ = salt.loader.minion_mods(__opts__) return __virtualname__ return False diff --git a/salt/log/setup.py b/salt/log/setup.py index d91c3b6043..5dc97489f7 100644 --- a/salt/log/setup.py +++ b/salt/log/setup.py @@ -678,7 +678,10 @@ def setup_extended_logging(opts): initial_handlers = logging.root.handlers[:] # Load any additional logging handlers - providers = salt.loader.log_handlers(opts) + # Pack the handlers with exec modules and grains + funcs = salt.loader.minion_mods(opts) + grains = salt.loader.grains(opts) + providers = salt.loader.log_handlers(opts, functions=funcs, grains=grains) # Let's keep track of the new logging handlers so we can sync the stored # log records with them