Skip to content

Commit

Permalink
Add version info and better logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuyukai committed Jan 20, 2016
1 parent dbe2c6e commit 8134441
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import logging
import os

from flask import Flask

import init

__version__ = "0.2.0 Ship Building Simulator 2016 Edition"

app = Flask(__name__)


formatter = logging.Formatter('%(asctime)s - [%(levelname)s] %(name)s -> %(message)s')
root = logging.getLogger()
root.setLevel(app.config.get("LOG_LEVEL", logging.INFO))
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(formatter)
root.addHandler(consoleHandler)

logger = logging.getLogger("kcsrv")

if not os.path.exists('./config.py'):
print("Config file does not exist. You must copy config.example.py to config.py and change the values.")
exit(1)
Expand All @@ -24,4 +36,6 @@
#sys.stdout = codecs.getwriter('utf8')(sys.stdout)
#sys.stderr = codecs.getwriter('utf8')(sys.stderr)

logger.info("Kan'tColle Server {} starting...".format(__version__))

init.init(app)
8 changes: 4 additions & 4 deletions kcsrv.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
import logging

from app import app
from app import app, logger

logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
root = logging.getLogger()
root.setLevel(logging.DEBUG)


if __name__ == '__main__':
print("Warning: This is a debugging configuration. Run with the gunicorn script to run in production.")

logger.warn("This is a debugging configuration. Run with the gunicorn script to run in production.")
app.run(host='0.0.0.0', debug=True)

0 comments on commit 8134441

Please sign in to comment.