from flask import Flask
from flask.ext.login import login_user, logout_user, current_user, login_required, LoginManager
from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask, session
from flask.ext.session import Session
from flask.ext.mail import Mail

app = Flask(__name__)

# Configuration file reading
app.config.from_object('config')

# Database Initialization
db = SQLAlchemy(app)

# Login manager init
lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'

# Session Manager Init
sess = Session()
sess.init_app(app)

# Mail engine init
mail = Mail(app)

from app import views, models

from flask import Flask
from flask.ext.login import login_user, logout_user, current_user, login_required, LoginManager
from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask, session
from flask.ext.session import Session
from flask.ext.mail import Mail
import logging
from logging.handlers import RotatingFileHandler

app = Flask(__name__)

# Configuration file reading
app.config.from_object('config')

# Database Initialization
db = SQLAlchemy(app)

# Login manager init
lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'

# Session Manager Init
sess = Session()
sess.init_app(app)

# Mail engine init
mail = Mail(app)

##################
# Logging system #
##################

# Open a file rotated every 100MB
file_handler = RotatingFileHandler('tmp/cineapp.log', 'a', 100 * 1024 * 1024, 10)
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
app.logger.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
app.logger.info('Cineapp startup')

from app import views, models

Enable file logging for the application.
Enable file logging for the application.
