Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Serverless Applications with Python

You're reading from   Building Serverless Applications with Python Develop fast, scalable, and cost-effective web applications that are always available

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher
ISBN-13 9781787288676
Length 272 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Jalem Raj Rohit Jalem Raj Rohit
Author Profile Icon Jalem Raj Rohit
Jalem Raj Rohit
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. The Serverless Paradigm 2. Building a Serverless Application in AWS FREE CHAPTER 3. Setting Up Serverless Architectures 4. Deploying Serverless APIs 5. Logging and Monitoring 6. Scaling Up Serverless Architectures 7. Security in AWS Lambda 8. Deploying a Lambda Function with SAM 9. Introduction to Microsoft Azure Functions 10. Other Books You May Enjoy

Logging statements in Lambda

Logging your comments and errors clearly is always a good software practice. So, we shall now understand how to log from inside of Lambda functions. There are broadly two ways of logging inside Lambda functions. We shall now learn and understand them via examples from the following steps:

  1. The first way is to use Python's logging library. This is widely used as a standard practice for logging in Python scripts. We shall edit the code we have written previously for the serverless API and add in the logging statements in it. The code will look like this:

The code which is in the preceding screenshot is as follows:

import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
mobs = {
"Sea": ["GoldFish", "Turtle", "Tortoise", "Dolphin", "Seal&quot...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image