mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
Remove the RequestLogMiddleware.
It doesn't play nicely with the new uWSGI setup and we don't use it.
This commit is contained in:
@@ -84,8 +84,6 @@ monitored_servers = reddit, localhost
|
||||
# name of the cookie to drop with login information
|
||||
login_cookie = reddit_session
|
||||
|
||||
# set to a path to enable per-request logging
|
||||
log_path =
|
||||
# fraction of requests to pass into the queue-based usage sampler
|
||||
usage_sampling = 0.
|
||||
|
||||
|
||||
@@ -438,31 +438,6 @@ class RewriteMiddleware(object):
|
||||
|
||||
return self.app(environ, start_response)
|
||||
|
||||
class RequestLogMiddleware(object):
|
||||
def __init__(self, log_path, process_iden, app):
|
||||
self.log_path = log_path
|
||||
self.app = app
|
||||
self.process_iden = str(process_iden)
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
request = '\n'.join('%s: %s' % (k,v) for k,v in environ.iteritems()
|
||||
if k.isupper())
|
||||
iden = self.process_iden + '-' + sha.new(request).hexdigest()
|
||||
|
||||
fname = os.path.join(self.log_path, iden)
|
||||
f = open(fname, 'w')
|
||||
f.write(request)
|
||||
f.close()
|
||||
|
||||
r = self.app(environ, start_response)
|
||||
|
||||
if os.path.exists(fname):
|
||||
try:
|
||||
os.remove(fname)
|
||||
except OSError:
|
||||
pass
|
||||
return r
|
||||
|
||||
class LimitUploadSize(object):
|
||||
"""
|
||||
Middleware for restricting the size of uploaded files (such as
|
||||
@@ -560,11 +535,6 @@ def make_app(global_conf, full_stack=True, **app_conf):
|
||||
app = ExtensionMiddleware(app)
|
||||
app = DomainMiddleware(app)
|
||||
|
||||
log_path = global_conf.get('log_path')
|
||||
if log_path:
|
||||
process_iden = global_conf.get('scgi_port', 'default')
|
||||
app = RequestLogMiddleware(log_path, process_iden, app)
|
||||
|
||||
#TODO: breaks on 404
|
||||
#app = make_gzip_middleware(app, app_conf)
|
||||
|
||||
|
||||
@@ -296,18 +296,6 @@ class Globals(object):
|
||||
else:
|
||||
self.static_names = {}
|
||||
|
||||
#set up the logging directory
|
||||
log_path = self.log_path
|
||||
process_iden = global_conf.get('scgi_port', 'default')
|
||||
self.reddit_port = process_iden
|
||||
if log_path:
|
||||
if not os.path.exists(log_path):
|
||||
os.makedirs(log_path)
|
||||
for fname in os.listdir(log_path):
|
||||
if fname.startswith(process_iden):
|
||||
full_name = os.path.join(log_path, fname)
|
||||
os.remove(full_name)
|
||||
|
||||
#setup the logger
|
||||
self.log = logging.getLogger('reddit')
|
||||
self.log.addHandler(logging.StreamHandler())
|
||||
|
||||
@@ -33,7 +33,7 @@ Q = 'log_q'
|
||||
def _default_dict():
|
||||
return dict(time=datetime.now(tz),
|
||||
host=g.reddit_host,
|
||||
port=g.reddit_port,
|
||||
port="default",
|
||||
pid=g.reddit_pid)
|
||||
|
||||
# e_value and e should actually be the same thing.
|
||||
|
||||
Reference in New Issue
Block a user