Hi I want to log the time it took to serve each request in my Flask App. So I plan to measure start-time in @app.before_request And log the difference in @app.after_request I have a few questions : - How can I pass information between before and after Methods. - How can I log the times. How can I access the logger configured for the Flask App (as given in Error Handling tutorial). Regards -Abhishek Kona Software Engineer - Platform. Flipkart.com
Le 22/12/2011 11:40, Abhishek K a écrit : > Hi > > I want to log the time it took to serve each request in my Flask App. > > So I plan to measure start-time in > @app.before_request > And log the difference in > @app.after_request > > I have a few questions : > > * How can I pass information between before and after Methods. > * How can I log the times. How can I access the logger configured for > the Flask App (as given in Error Handling tutorial). Hi, You can add attributes to the "g" object, they will stay there for the life-time of the request. The configured logger is in app.logger. http://flask.pocoo.org/docs/api/#flask.g http://flask.pocoo.org/docs/api/#flask.Flask.logger Regards, -- Simon Sapin
By the way is flipkart running on flask? ... On 22-Dec-2011 4:28 PM, "Simon Sapin" <simon.sapin@exyr.org> wrote: > Le 22/12/2011 11:40, Abhishek K a écrit : > > Hi > > > > I want to log the time it took to serve each request in my Flask App. > > > > So I plan to measure start-time in > > @app.before_request > > And log the difference in > > @app.after_request > > > > I have a few questions : > > > > * How can I pass information between before and after Methods. > > * How can I log the times. How can I access the logger configured for > > the Flask App (as given in Error Handling tutorial). > > Hi, > > You can add attributes to the "g" object, they will stay there for the > life-time of the request. The configured logger is in app.logger. > > http://flask.pocoo.org/docs/api/#flask.g > http://flask.pocoo.org/docs/api/#flask.Flask.logger > > Regards, > -- > Simon Sapin >
On Thu, Dec 22, 2011 at 8:29 PM, alice ni <alice.ni19@gmail.com> wrote: > By the way is flipkart running on flask? ... > No. they use java. :(. > On 22-Dec-2011 4:28 PM, "Simon Sapin" <simon.sapin@exyr.org> wrote: > >> Le 22/12/2011 11:40, Abhishek K a écrit : >> > Hi >> > >> > I want to log the time it took to serve each request in my Flask App. >> > >> > So I plan to measure start-time in >> > @app.before_request >> > And log the difference in >> > @app.after_request >> > >> > I have a few questions : >> > >> > * How can I pass information between before and after Methods. >> > * How can I log the times. How can I access the logger configured for >> > the Flask App (as given in Error Handling tutorial). >> >> Hi, >> >> You can add attributes to the "g" object, they will stay there for the >> life-time of the request. The configured logger is in app.logger. >> >> http://flask.pocoo.org/docs/api/#flask.g >> http://flask.pocoo.org/docs/api/#flask.Flask.logger >> >> Regards, >> -- >> Simon Sapin >> > -- * Thanks & Regards "Talk is cheap, show me the code" -- Linus Torvalds kracekumar www.kracekumar.com *