#!/usr/bin/env python
import logging
import sys
from app import app as application


def setup_flask_logging():
    # Log to stdout
    handler = logging.StreamHandler(sys.stdout)
    # Log to a file
    #handler = logging.FileHandler('./application.log')
    handler.setLevel(logging.INFO)
    handler.setFormatter(logging.Formatter(
        '%(asctime)s [%(funcName)s] %(levelname)s: %(message)s '
    ))
    application.logger.addHandler(handler)


# Set default log level for the general logger
# each handler can then restrict the messages logged
application.logger.setLevel(logging.INFO)
setup_flask_logging()


if __name__ == '__main__':
    application.run()

[((21, 0, 21, 41), 'app.app.logger.setLevel', 'application.logger.setLevel', ({(21, 28, 21, 40): 'logging.INFO'}, {}), '(logging.INFO)', True, 'from app import app as application\n'), ((9, 14, 9, 47), 'logging.StreamHandler', 'logging.StreamHandler', ({(9, 36, 9, 46): 'sys.stdout'}, {}), '(sys.stdout)', False, 'import logging\n'), ((16, 4, 16, 42), 'app.app.logger.addHandler', 'application.logger.addHandler', ({(16, 34, 16, 41): 'handler'}, {}), '(handler)', True, 'from app import app as application\n'), ((26, 4, 26, 21), 'app.app.run', 'application.run', ({}, {}), '()', True, 'from app import app as application\n'), ((13, 25, 15, 5), 'logging.Formatter', 'logging.Formatter', ({(14, 8, 14, 64): '"""%(asctime)s [%(funcName)s] %(levelname)s: %(message)s """'}, {}), "('%(asctime)s [%(funcName)s] %(levelname)s: %(message)s ')", False, 'import logging\n')]