mirror of
https://github.com/devplayer0/docker-net-dhcp
synced 2024-11-18 21:28:05 +00:00
Log exceptions
This commit is contained in:
parent
ec164efe30
commit
895e9aa9c4
@ -1,13 +1,18 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from flask import Flask, jsonify
|
from flask import Flask, jsonify
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
from . import network
|
from . import network
|
||||||
|
|
||||||
|
logger = logging.getLogger('gunicorn.error')
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def err_not_found(e):
|
def err_not_found(e):
|
||||||
return jsonify({'Err': 'API not found'}), 404
|
return jsonify({'Err': 'API not found'}), 404
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
@app.errorhandler(Exception)
|
||||||
def err(e):
|
def err(e):
|
||||||
|
logger.exception(e)
|
||||||
return jsonify({'Err': f'Error: {e}'}), 500
|
return jsonify({'Err': f'Error: {e}'}), 500
|
||||||
|
Loading…
Reference in New Issue
Block a user