#!/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()

[((552, 593), 'app.app.logger.setLevel', 'application.logger.setLevel', (['logging.INFO'], {}), '(logging.INFO)\n', (579, 593), True, 'from app import app as application\n'), ((146, 179), 'logging.StreamHandler', 'logging.StreamHandler', (['sys.stdout'], {}), '(sys.stdout)\n', (167, 179), False, 'import logging\n'), ((411, 449), 'app.app.logger.addHandler', 'application.logger.addHandler', (['handler'], {}), '(handler)\n', (440, 449), True, 'from app import app as application\n'), ((649, 666), 'app.app.run', 'application.run', ([], {}), '()\n', (664, 666), True, 'from app import app as application\n'), ((316, 391), 'logging.Formatter', 'logging.Formatter', (['"""%(asctime)s [%(funcName)s] %(levelname)s: %(message)s """'], {}), "('%(asctime)s [%(funcName)s] %(levelname)s: %(message)s ')\n", (333, 391), False, 'import logging\n')]