Skip to content
Snippets Groups Projects
Unverified Commit 047cef84 authored by James Curtin's avatar James Curtin
Browse files

Fix logging issue

Closes #247
parent 5d7f8ab3
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,8 @@ def test(ctx):
os.chdir(COOKIE)
shutil.copyfile(os.path.join(COOKIE, '.env.example'),
os.path.join(COOKIE, '.env'))
os.environ["FLASK_ENV"] = "production"
os.environ["FLASK_DEBUG"] = "0"
_run_flask_command(ctx, 'lint')
_run_flask_command(ctx, 'test')
......
......@@ -43,6 +43,9 @@ services:
build:
context: .
target: manage
environment:
FLASK_ENV: production
FLASK_DEBUG: 0
image: "{{cookiecutter.app_name}}-manage"
stdin_open: true
tty: true
......
# -*- coding: utf-8 -*-
"""The app module, containing the app factory function."""
import logging
import sys
from flask import Flask, render_template
from {{cookiecutter.app_name}} import commands, public, user
......@@ -18,6 +21,7 @@ def create_app(config_object='{{cookiecutter.app_name}}.settings'):
register_errorhandlers(app)
register_shellcontext(app)
register_commands(app)
configure_logger(app)
return app
......@@ -70,3 +74,10 @@ def register_commands(app):
app.cli.add_command(commands.lint)
app.cli.add_command(commands.clean)
app.cli.add_command(commands.urls)
def configure_logger(app):
"""Configure loggers."""
handler = logging.StreamHandler(sys.stdout)
if not app.logger.handlers:
app.logger.addHandler(handler)
# -*- coding: utf-8 -*-
"""Public section, including homepage and signup."""
from flask import Blueprint, flash, redirect, render_template, request, url_for
from flask import Blueprint, current_app, flash, redirect, render_template, request, url_for
from flask_login import login_required, login_user, logout_user
from {{cookiecutter.app_name}}.extensions import login_manager
......@@ -22,6 +22,7 @@ def load_user(user_id):
def home():
"""Home page."""
form = LoginForm(request.form)
current_app.logger.info('Hello from the home page!')
# Handle logging in
if request.method == 'POST':
if form.validate_on_submit():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment