Skip to content

Commit 61ddd2e

Browse files
Add some logging
1 parent fe8694a commit 61ddd2e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

todo_app/app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def index():
1616
@app.route('/add', methods=['POST'])
1717
def add():
1818
title = request.form.get('title')
19+
20+
app.logger.info(f'Adding new item: {title}')
21+
1922
add_mongo_item(title)
2023
return redirect('/')
2124

@@ -24,8 +27,15 @@ def update_status():
2427
item_id = request.form.get('item_id')
2528
status = request.form.get('status')
2629

30+
app.logger.info(f'Updating status of item {item_id} to {status}')
31+
2732
update_mongo_item_status(item_id, ItemStatus(status))
2833

2934
return redirect('/')
3035

36+
@app.errorhandler(Exception)
37+
def handle_exception(e):
38+
app.logger.info(f'Exception: {e}')
39+
return e
40+
3141
return app

0 commit comments

Comments
 (0)