So i have tried doing this a few different ways. i am trying to use the flask app.logger to save messages with MYSQL database without using the SQLalchdb handler (i dont use SQLalch for anything)
anyways.... when i use app.logger with a filehandler, everything works correctly
when i use my http handler outside of flask, and have the flask route programmed to catch the error, it also works
but when i use app.logger and add the http handler to it, it does not work. have a look at my code and tell me what your think
http_handler = logging.handlers.HTTPHandler(
'localhost:5000',
'/logs',
method='POST',
)
app.logger.setLevel(logging.DEBUG)
app.logger.addHandler(http_handler)
and this is the flask route:
@app.route('/logs' , methods = ["GET","POST"])
def logs():
print('caught it')
print(request.form)
return ""
Here is the route i am using to force and error:
@app.route('/home', methods=['POST'])
def index():
[some code]
ender_template("index.html")
as previous mentioned, if i set up a new logger (not flask app.logger) with the same HTTP handler above it works, so i assume the flask route is set up correctly. also as previously mentioned, the flask app.logger will work with a file handler
Any help is greatly appreciated
EDIT:: Was recently asked to describe how the following code responds, figured it could be good information for everyone trying to help.
When i force flask to have an error (changed "render_template" to "ender_template" i see the error in the python shell, but it is not getting passed to the route. also, after i force the error flask no longer allows me to GET/POST anything until its restarted. i dont get any exceptions or errors for the logging function
/logsroute? Or specify method='GET' in the handler?