当前位置: 首页>>代码示例>>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;未经允许,请勿转载。