Reputation: 9536
How to print log in pytest
using AWS Chalice
framework?
The log prints everything if we use custom logger
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Run test with log-level (Working)
pytest --log-cli-level=DEBUG
If I use AWS chalice log
import logging
from chalice import Chalice
app = Chalice(app_name='demolog')
# Enable DEBUG logs.
app.log.setLevel(logging.DEBUG)
@app.route('/')
def index():
app.log.debug("This is a debug statement")
return {'hello': 'world'}
The same test command is not printing any log
pytest --log-cli-level=DEBUG
Any help?
Upvotes: 0
Views: 812
Reputation: 9536
from chalice import Chalice
import logging
app = Chalice(app_name='eballot-poll-role')
# Log
app.debug = True
logging.getLogger().setLevel(logging.DEBUG)
Upvotes: 0
Reputation: 2358
Make Sure your Chalice instance is in debug and you can also turn off configure_logs
app=Chalice(app_name="MyApp", debug=True, configure_logs=False)
Put your debug and configure_logs on environment variables and then you can control them based on local/dev/stage/prod environments.
Upvotes: 1