##// END OF EJS Templates
gunicorn: allow custom logger to set consistent formatting of requests for gunicorn with rhodecode logging.
marcink -
r2075:0e299543 default
parent child
Show More
@@ -15,8 +15,11 available post the .ini config.
15
15
16 import multiprocessing
16 import multiprocessing
17 import sys
17 import sys
18 import time
19 import datetime
18 import threading
20 import threading
19 import traceback
21 import traceback
22 from gunicorn.glogging import Logger
20
23
21
24
22 # GLOBAL
25 # GLOBAL
@@ -87,4 +90,24 def pre_request(worker, req):
87 def post_request(worker, req, environ, resp):
90 def post_request(worker, req, environ, resp):
88 return
91 return
89 worker.log.debug("[<%-10s>] POST WORKER: %s %s resp: %s", worker.pid,
92 worker.log.debug("[<%-10s>] POST WORKER: %s %s resp: %s", worker.pid,
90 req.method, req.path, resp.status_code) No newline at end of file
93 req.method, req.path, resp.status_code)
94
95
96 class RhodeCodeLogger(Logger):
97 """
98 Custom Logger that allows some customization that gunicorn doesn't allow
99 """
100
101 datefmt = r"%Y-%m-%d %H:%M:%S"
102
103 def __init__(self, cfg):
104 Logger.__init__(self, cfg)
105
106 def now(self):
107 """ return date in RhodeCode Log format """
108 now = time.time()
109 msecs = int((now - long(now)) * 1000)
110 return time.strftime(self.datefmt, time.localtime(now)) + '.{0:03d}'.format(msecs)
111
112
113 logger_class = RhodeCodeLogger
General Comments 0
You need to be logged in to leave comments. Login now