def setup_logging(): """ Set logging levels based on configuration. """ cfg = AgentConfig() for name, level in cfg.logging: if not level: continue try: logger = logging.getLogger(name) level = getattr(logging, level.upper()) logger.setLevel(level) except Exception, e: log.error(utf8(e))
def setup_logging(): """ Set logging levels based on configuration. The special name of 'root' is used to specify the root logger. """ cfg = AgentConfig() for name, level in cfg.logging: if not level: continue if name.lower() == 'root': name = None try: logger = logging.getLogger(name) level = getattr(logging, level.upper()) logger.setLevel(level) except Exception as e: log.error(str(e))
def start(self, block=True): """ Start the agent. """ cfg = AgentConfig() for plugin in Plugin.all(): plugin.start() if get_bool(cfg.manager.enabled): host = cfg.manager.host port = int(cfg.manager.port) manager = Manager(host, port) manager.start() actions = ActionThread() actions.start() log.info('agent started.') if block: actions.join(self.WAIT)
def __init__(self): cfg = AgentConfig()
def test_init(self, cfg): path = str(uuid4()) agent = AgentConfig(path) cfg.assert_called_once_with(AGENT_DEFAULTS, path) cfg.return_value.validate.assert_called_once_with(AGENT_SCHEMA) self.assertTrue(isinstance(agent, Graph))
def __init__(self): cfg = AgentConfig() pam.SERVICE = cfg.pam.service