Skip to content

Commit

Permalink
Add a simple best practices logging demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Feb 14, 2019
1 parent d2c6a59 commit 9f8a1e5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import os, logging

from chalice import Chalice

log_level = logging.getLevelName(os.environ.get("LOG_LEVEL", "INFO"))
logging.basicConfig(level=log_level)
logging.getLogger().setLevel(log_level)

app = Chalice(app_name='chalice-app-template')
app.debug = True if log_level == logging.DEBUG else False

logger = logging.getLogger(__name__)

@app.route('/')
def index():
app.log.debug("This is a debug logging test with the app logger")
app.log.error("This is an error logging test with the app logger")
logger.debug("This is a debug logging test with the module logger")
logger.error("This is an error logging test with the module logger")
return {'hello': 'world'}


Expand Down

0 comments on commit 9f8a1e5

Please sign in to comment.