當前位置: 首頁>>代碼示例>>Python>>正文


Python logfile.Log類代碼示例

本文整理匯總了Python中haproxy.logfile.Log的典型用法代碼示例。如果您正苦於以下問題:Python Log類的具體用法?Python Log怎麽用?Python Log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Log類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cmd_queue_peaks

    def test_cmd_queue_peaks(self):
        """Check that the queue peaks command reports as expected."""
        log_file = Log(
            logfile='haproxy/tests/files/queue.log',
        )
        peaks = log_file.cmd_queue_peaks()

        self.assertEqual(len(peaks), 4)
        self.assertEqual(peaks[0]['peak'], 4)
        self.assertEqual(peaks[0]['span'], 5)

        self.assertEqual(peaks[1]['peak'], 19)
        self.assertEqual(peaks[1]['span'], 5)

        self.assertEqual(peaks[2]['peak'], 49)
        self.assertEqual(peaks[2]['span'], 3)

        self.assertEqual(peaks[3]['peak'], 3)
        self.assertEqual(peaks[3]['span'], 1)

        self.assertTrue(peaks[0]['first'] < peaks[1]['first'])
        self.assertTrue(peaks[1]['first'] < peaks[2]['first'])
        self.assertTrue(peaks[2]['first'] < peaks[3]['first'])

        self.assertTrue(peaks[0]['last'] < peaks[1]['last'])
        self.assertTrue(peaks[1]['last'] < peaks[2]['last'])
        self.assertTrue(peaks[2]['last'] < peaks[3]['last'])
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:27,代碼來源:test_log_file.py

示例2: test_cmd_average_response_time

 def test_cmd_average_response_time(self):
     """Check that the average response time returns the expected output."""
     log_file = Log(
         logfile='haproxy/tests/files/average_response.log',
     )
     data = log_file.cmd_average_response_time()
     self.assertEqual(data, 105)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:7,代碼來源:test_log_file.py

示例3: test_cmd_requests_per_minute

    def test_cmd_requests_per_minute(self):
        """Check that the requests per minute command reports as expected."""
        log_file = Log(
            logfile='haproxy/tests/files/requests_per_minute.log',
        )
        requests = log_file.cmd_requests_per_minute()

        self.assertEqual(len(requests), 5)

        self.assertEqual(
            requests[0],
            (datetime(2013, 12, 11, 11, 2), 8)
        )
        self.assertEqual(
            requests[1],
            (datetime(2013, 12, 11, 11, 3), 3)
        )
        self.assertEqual(
            requests[2],
            (datetime(2013, 12, 11, 11, 13), 5)
        )
        self.assertEqual(
            requests[3],
            (datetime(2013, 12, 11, 11, 52), 7)
        )
        self.assertEqual(
            requests[4],
            (datetime(2013, 12, 11, 12, 2), 9)
        )
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:29,代碼來源:test_log_file.py

示例4: test_cmd_counter_slow_requests

    def test_cmd_counter_slow_requests(self):
        """Check that the slow requests counter command reports as expected.
        """
        log_file = Log(
            logfile='haproxy/tests/files/small.log',
        )
        slow_requests = log_file.cmd_counter_slow_requests()

        self.assertEqual(slow_requests, 5)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例5: test_cmd_average_waiting_time_empty_log

 def test_cmd_average_waiting_time_empty_log(self):
     """Check that the average time waiting on queues does not break if no
     log lines are logged.
     """
     log_file = Log(
         logfile='haproxy/tests/files/empty.log',
     )
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 0)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例6: test_cmd_average_waiting_time

 def test_cmd_average_waiting_time(self):
     """Check that the average time waiting on queues returns the expected
     output.
     """
     log_file = Log(
         logfile='haproxy/tests/files/average_waiting.log',
     )
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 105)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例7: test_cmd_average_waiting_time_aborted

 def test_cmd_average_waiting_time_aborted(self):
     """Check that the average time waiting on queues returns the expected
     output when there are aborted connections.
     """
     log_file = Log(
         logfile='haproxy/tests/files/average_waiting_aborted.log',
     )
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 110)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例8: test_cmd_average_response_time_no_wait

 def test_cmd_average_response_time_no_wait(self):
     """Check that the average response time returns the expected output
     when there are connections that did not take any millisecond to reply.
     """
     log_file = Log(
         logfile='haproxy/tests/files/average_response_no_wait.log',
     )
     data = log_file.cmd_average_response_time()
     self.assertEqual(data, 74)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例9: test_cmd_print_empty

 def test_cmd_print_empty(self):
     """Check that the print command prints an empty string if the log file
     is empty.
     """
     log_file = Log(
         logfile='haproxy/tests/files/empty.log',
     )
     data = log_file.cmd_print()
     self.assertEqual('', data)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例10: test_cmd_connection_type

    def test_cmd_connection_type(self):
        """Check that the connection type command reports as expected."""
        log_file = Log(
            logfile='haproxy/tests/files/connection.log',
        )
        ssl, non_ssl = log_file.cmd_connection_type()

        self.assertEqual(ssl, 7)
        self.assertEqual(non_ssl, 5)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例11: test_valid_and_invalid_lines

 def test_valid_and_invalid_lines(self):
     """Check that if some log lines can not be parsed both numbers are
     correctly reported.
     """
     log_file = Log(
         logfile='haproxy/tests/files/2_ok_1_invalid.log'
     )
     self.assertEqual(log_file.cmd_counter(), 2)
     self.assertEqual(log_file.cmd_counter_invalid(), 1)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:9,代碼來源:test_log_file.py

示例12: test_cmd_print

    def test_cmd_print(self):
        """Check that the print command prints the valid lines."""
        log_file = Log(
            logfile='haproxy/tests/files/2_ok_1_invalid.log',
        )
        data = log_file.cmd_print()
        self.assertNotEqual('', data)

        lines = data.split('\n')
        self.assertEqual(len(lines), 3)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:10,代碼來源:test_log_file.py

示例13: test_cmd_average_waiting_time_no_wait

 def test_cmd_average_waiting_time_no_wait(self):
     """Check that the average time waiting on queues returns the expected
     output when there are requests that did not wait at all (i.e.
     time_wait_queues is 0).
     """
     log_file = Log(
         logfile='haproxy/tests/files/average_waiting_no_wait.log',
     )
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 52.5)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:10,代碼來源:test_log_file.py

示例14: test_cmd_requests_per_minute_empty

    def test_cmd_requests_per_minute_empty(self):
        """Check that the requests per minute command reports nothing if
        there are no valid lines for whichever reason.
        """
        log_file = Log(
            logfile='haproxy/tests/files/empty.log',
        )
        requests = log_file.cmd_requests_per_minute()

        self.assertEqual(None, requests)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:10,代碼來源:test_log_file.py

示例15: test_cmd_status_codes

    def test_cmd_status_codes(self):
        """Check that the status codes command reports as expected."""
        log_file = Log(
            logfile='haproxy/tests/files/small.log',
        )
        status_codes = log_file.cmd_status_codes_counter()

        self.assertEqual(len(status_codes), 3)
        self.assertEqual(status_codes['404'], 3)
        self.assertEqual(status_codes['200'], 2)
        self.assertEqual(status_codes['300'], 4)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:11,代碼來源:test_log_file.py


注:本文中的haproxy.logfile.Log類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。