How to use the solnlib.log.Logs.set_context function in solnlib

To help you get started, we’ve selected a few solnlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto / modinput_wrapper / base_modinput.py View on Github external
def __init__(self, app_namespace, input_name, use_single_instance=False):
        super(BaseModInput, self).__init__()
        self.use_single_instance = use_single_instance
        self._canceled = False
        self.input_type = input_name
        self.input_stanzas = {}
        self.context_meta = {}
        self.namespace = app_namespace
        # redirect all the logging to one file
        Logs.set_context(namespace=app_namespace,
                         root_logger_log_file=input_name)
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.INFO)
        self.rest_helper = TARestHelper(self.logger)
        # check point
        self.ckpt = None
        self.setup_util = None
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup.py View on Github external
handleEdit method: controls the parameters and saves the values
    corresponds to handleractions = edit in restmap.conf
"""
import splunk_ta_paloalto_declare

import json
import splunk.clilib.cli_common as scc
import splunk.admin as admin


import solnlib.utils as utils
import solnlib.log as log
import solnlib.conf_manager as conf
import splunk_ta_paloalto_consts as setup_const

log.Logs.set_context(namespace="splunk_ta_paloalto")
logger = log.Logs().get_logger("setup")

def get_or_create_conf_file(conf_mgr, file_name):
    try:
        conf_file = conf_mgr.get_conf(file_name)
        return conf_file
    except conf.ConfManagerException as cme:
        conf_mgr._confs.create(file_name)
        return conf_mgr.get_conf(file_name, refresh=True)

def filter_eai_property(stanza):
    if isinstance(stanza, dict):
        for k in list(stanza.keys()):
            if k.startswith('eai:'):
                del stanza[k]
            else:
github PaloAltoNetworks / pandevice / install / Splunk_TA_paloalto / bin / splunk_ta_paloalto / modinput_wrapper / base_modinput.py View on Github external
def __init__(self, app_namespace, input_name):
        super(BaseModInput, self).__init__()
        self._canceled = False
        self.input_name = None
        self.input_stanzas = {}
        self.context_meta = {}
        self.namespace = app_namespace
        # redirect all the logging to one file
        Logs.set_context(namespace=app_namespace,
                         root_logger_log_file=input_name)
        self.logger = logging.getLogger()
        self.logger.setLevel(logging.INFO)
        self.http_session = None
        self.requests_proxy = None
        # check point
        self.ckpt = None
        # try to load the setup util module
        self.setup_util_module = None
        self.setup_util = None
        try:
            self.setup_util_module = importlib.import_module(self.namespace +
                                                             "_setup_util")
        except ImportError as ie:
            self.logger.info("Can not import package:" +
                             self.namespace + "_setup_util")
github PaloAltoNetworks / Splunk_TA_paloalto / bin / splunk_ta_paloalto_setup.py View on Github external
handleEdit method: controls the parameters and saves the values
    corresponds to handleractions = edit in restmap.conf
"""
import splunk_ta_paloalto_declare

import json
import splunk.clilib.cli_common as scc
import splunk.admin as admin


import solnlib.utils as utils
import solnlib.log as log
import solnlib.conf_manager as conf
import splunk_ta_paloalto_consts as setup_const

log.Logs.set_context(namespace="splunk_ta_paloalto")
logger = log.Logs().get_logger("setup")

def get_or_create_conf_file(conf_mgr, file_name):
    try:
        conf_file = conf_mgr.get_conf(file_name)
        return conf_file
    except conf.ConfManagerException as cme:
        conf_mgr._confs.create(file_name)
        return conf_mgr.get_conf(file_name, refresh=True)

def filter_eai_property(stanza):
    if isinstance(stanza, dict):
        for k in list(stanza.keys()):
            if k.startswith('eai:'):
                del stanza[k]
            else: