python - Is there a way to include the useragent in the error log? -


I have a flaszk setup when I get an email, but I want to add UserAgent to that email. Is this possible? I did not see it in.

Edit: Link says that more documents can be found in official documents but there are no official documents? (I say the same thing)

I came to know how to do this intensive. To add a user-agent to record, you have to set up a new filter. It appears that in the filter phase, you can use the request object to obtain the object that you are using. So you are not actually filtering anything, but adding more to the log record functional example: importing logging.handlers import from SMTPHandler class ContextualFilter (logging.Filter) Import: Def filter it (

 Import bottle, request application = bottle (__ name__) if not from app.debug  self, log_record): log_record.user_agent = request.user_agent true context_provider return = ContextualFilter () app.logger.addFilter (context_provider) mail_handler = SMTPHandler ('127.0.0.1', 'apperror@example.com', app.config ['admin'], 'application failed') mail_handler.setFormatter ( Logging.Formatter ("" "Message type:% (levelname) Location:% (path) are:% (lineno) d module:% (module) function:% (funcName) time:% (asctime) user -Agent:% (USER_AGENT) message:% (message) s "" ")) mail_handler.setLevel (logging.ERROR) app.logger.addHandler (mail_handler)  

use it For, I was able to receive emails sent for my error logs.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -