Show More
@@ -0,0 +1,27 b'' | |||
|
1 | # -*- coding: utf-8 -*- | |
|
2 | ||
|
3 | # Copyright (C) 2017-2019 RhodeCode GmbH | |
|
4 | # | |
|
5 | # This program is free software: you can redistribute it and/or modify | |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
|
7 | # (only), as published by the Free Software Foundation. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
|
16 | # | |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
|
20 | ||
|
21 | counter = 0 | |
|
22 | ||
|
23 | ||
|
24 | def get_request_counter(request): | |
|
25 | global counter | |
|
26 | counter += 1 | |
|
27 | return counter |
@@ -317,6 +317,10 b' def includeme(config):' | |||
|
317 | 317 | 'rhodecode.lib.partial_renderer.get_partial_renderer', |
|
318 | 318 | 'get_partial_renderer') |
|
319 | 319 | |
|
320 | config.add_request_method( | |
|
321 | 'rhodecode.lib.request_counter.get_request_counter', | |
|
322 | 'request_count') | |
|
323 | ||
|
320 | 324 | # Set the authorization policy. |
|
321 | 325 | authz_policy = ACLAuthorizationPolicy() |
|
322 | 326 | config.set_authorization_policy(authz_policy) |
@@ -18,11 +18,10 b'' | |||
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | ||
|
21 | import gc | |
|
22 | 22 | import time |
|
23 | 23 | import logging |
|
24 | 24 | |
|
25 | ||
|
26 | 25 | from rhodecode.lib.base import get_ip_addr, get_access_path, get_user_agent |
|
27 | 26 | from rhodecode.lib.utils2 import safe_str |
|
28 | 27 | |
@@ -44,9 +43,10 b' class RequestWrapperTween(object):' | |||
|
44 | 43 | finally: |
|
45 | 44 | end = time.time() |
|
46 | 45 | total = end - start |
|
46 | count = request.request_count() | |
|
47 | 47 | log.info( |
|
48 | 'IP: %s %s Request to %s time: %.4fs [%s]', | |
|
49 | get_ip_addr(request.environ), request.environ.get('REQUEST_METHOD'), | |
|
48 | 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s]', | |
|
49 | count, get_ip_addr(request.environ), request.environ.get('REQUEST_METHOD'), | |
|
50 | 50 | safe_str(get_access_path(request.environ)), total, |
|
51 | 51 | get_user_agent(request. environ) |
|
52 | 52 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now