Ejemplo n.º 1
0
    def test_log_path_specs_path(self):
        """The handler can specify either the container or full log path."""

        # Verify default log path location
        handler = ZookeeperHandler(self.client, "something")
        self.assertEqual(handler.log_path, "/logs/log-")

        # Specify a log path
        handler = ZookeeperHandler(self.client,
                                   "something",
                                   log_path="/logs/msg-")
        self.assertEqual(handler.log_path, "/logs/msg-")
Ejemplo n.º 2
0
 def start_debug_log(self):
     """Enable the distributed debug log handler.
     """
     if self._debug_log_handler is not None:
         returnValue(None)
     context_name = self.get_agent_name()
     self._debug_log_handler = ZookeeperHandler(self.client, context_name)
     yield self._debug_log_handler.open()
     log_root = logging.getLogger()
     log_root.addHandler(self._debug_log_handler)
Ejemplo n.º 3
0
 def get_configured_log(self,
                        channel="test-zk-log",
                        context_name="unit:mysql/0"):
     """Get a log channel configured with a zk handler.
     """
     log = logging.getLogger(channel)
     log.setLevel(logging.DEBUG)
     handler = ZookeeperHandler(self.client, context_name)
     yield handler.open()
     log.addHandler(handler)
     returnValue(log)
Ejemplo n.º 4
0
 def test_open_with_nonexisting_container_path(self):
     handler = ZookeeperHandler(self.client, "unit:mysql/0")
     # should not raise exception
     yield handler.open()
     exists = yield self.client.exists("/logs")
     self.assertTrue(exists)
Ejemplo n.º 5
0
 def test_open_with_existing_container_path(self):
     yield self.client.create("/logs")
     handler = ZookeeperHandler(self.client, "unit:mysql/0")
     # should not raise exception
     yield handler.open()
Ejemplo n.º 6
0
 def test_log_container_path(self):
     handler = ZookeeperHandler(self.client, "unit:mysql/0")
     self.assertEqual(handler.log_container_path, "/logs")