Ejemplo n.º 1
0
def distlog_get_log_content(panel, app_id=None, hostname=None, log_id=None, lines=100):
    panel.logger.info(
        "Remote control distlog_get_log_content request, "
        "app_id=%s hostname=%s log_id=%s lines=%d." % (app_id, hostname, log_id, lines)
    )
    if not (app_id and log_id and hostname):
        return None

    if hostname != MY_HOSTNAME:
        return None

    return logs.get_log_content(app_id, log_id, lines)
Ejemplo n.º 2
0
    def test_getting_log_content(self):
        self._ensure_test_logs_exist()

        log_list = list(logs.get_available_logs(self.app_id))
        self.assertTrue(len(log_list) > 0, log_list)

        for loginfo in log_list:
            log_id = loginfo["log_id"]
            caption = loginfo["caption"]
            filesize = loginfo["filesize"]
            mod_time = loginfo["mod_time"]

            self.assertTrue(isinstance(mod_time, float))

            print "LOG: %s: %s, %d bytes" % (caption, log_id, filesize)

            content = logs.get_log_content(self.app_id, log_id)
            self.assertTrue(isinstance(content, str), content)
Ejemplo n.º 3
0
 def test_getting_wrong_log_content(self):
     with self.assertRaises(logs.UnavailableLogError):
         logs.get_log_content(self.app_id, "/etc/passwd")