diff options
author | ianb <devnull@localhost> | 2006-10-20 18:39:34 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-10-20 18:39:34 +0000 |
commit | b46c17a62ff0536926f79c188fc3c23d3955d467 (patch) | |
tree | a90346b1690e36b5fa1c44c05ed08d6de513f424 /paste/debug | |
parent | 315957c3dd7a71957a15b4fa2048601247ecae83 (diff) | |
download | paste-b46c17a62ff0536926f79c188fc3c23d3955d467.tar.gz |
Moved profile entry point
Diffstat (limited to 'paste/debug')
-rw-r--r-- | paste/debug/profile.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/paste/debug/profile.py b/paste/debug/profile.py index b235f74..cf4f085 100644 --- a/paste/debug/profile.py +++ b/paste/debug/profile.py @@ -22,11 +22,6 @@ class ProfileMiddleware(object): """ Middleware that profiles all requests. - - You can enable this middleware by adding this to your - configuration:: - - middleware.append('paste.profilemiddleware.ProfileMiddleware') All HTML pages will have profiling information appended to them. The data is isolated to that single request, and does not include @@ -40,7 +35,7 @@ class ProfileMiddleware(object): style = ('background-color: #ff9; color: #000; ' 'border: 2px solid #000; padding: 5px;') - def __init__(self, app, global_conf, + def __init__(self, app, global_conf=None, log_filename='profile.log.tmp', limit=40): self.app = app @@ -210,3 +205,18 @@ class DecoratedProfile(object): return '%s(%s)' % (func.__name__, ', '.join(args)) +def make_profile_middleware( + app, global_conf, + log_filename='profile.log.tmp', + limit=40): + """ + Wrap the application in a component that will profile each + request. The profiling data is then appended to the output + of each page. + + Note that this serializes all requests (i.e., removing + concurrency). Therefore never use this in production. + """ + limit = int(limit) + return ProfileMiddleware( + app, log_filename=log_filename, limit=limit) |