Show More
@@ -0,0 +1,19 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-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/ |
@@ -329,7 +329,7 b' class HTTPApplication(object):' | |||||
329 | self.config.add_view(self.handle_vcs_exception, context=Exception) |
|
329 | self.config.add_view(self.handle_vcs_exception, context=Exception) | |
330 |
|
330 | |||
331 | self.config.add_tween( |
|
331 | self.config.add_tween( | |
332 | 'vcsserver.tweens.RequestWrapperTween', |
|
332 | 'vcsserver.tweens.request_wrapper.RequestWrapperTween', | |
333 | ) |
|
333 | ) | |
334 |
|
334 | |||
335 | def wsgi_app(self): |
|
335 | def wsgi_app(self): |
@@ -32,6 +32,10 b' def get_access_path(request):' | |||||
32 | return environ.get('PATH_INFO') |
|
32 | return environ.get('PATH_INFO') | |
33 |
|
33 | |||
34 |
|
34 | |||
|
35 | def get_user_agent(environ): | |||
|
36 | return environ.get('HTTP_USER_AGENT') | |||
|
37 | ||||
|
38 | ||||
35 | class RequestWrapperTween(object): |
|
39 | class RequestWrapperTween(object): | |
36 | def __init__(self, handler, registry): |
|
40 | def __init__(self, handler, registry): | |
37 | self.handler = handler |
|
41 | self.handler = handler | |
@@ -45,14 +49,16 b' class RequestWrapperTween(object):' | |||||
45 | response = self.handler(request) |
|
49 | response = self.handler(request) | |
46 | finally: |
|
50 | finally: | |
47 | end = time.time() |
|
51 | end = time.time() | |
48 |
|
52 | total = end - start | ||
49 | log.info('IP: %s Request to path: `%s` time: %.4fs', |
|
53 | log.info( | |
50 | '127.0.0.1', safe_str(get_access_path(request)), end - start) |
|
54 | 'IP: %s %s Request to %s time: %.4fs [%s]', | |
|
55 | '127.0.0.1', request.environ.get('REQUEST_METHOD'), | |||
|
56 | safe_str(get_access_path(request)), total, get_user_agent(request.environ)) | |||
51 |
|
57 | |||
52 | return response |
|
58 | return response | |
53 |
|
59 | |||
54 |
|
60 | |||
55 | def includeme(config): |
|
61 | def includeme(config): | |
56 | config.add_tween( |
|
62 | config.add_tween( | |
57 | 'vcsserver.tweens.RequestWrapperTween', |
|
63 | 'vcsserver.tweens.request_wrapper.RequestWrapperTween', | |
58 | ) |
|
64 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now