Hello, and welcome back to the Python logging course. In today's lesson, lesson eight, we will learn about creating a logging decorator. So first, we're going to cover what a decorator is. Then we're going to create an exception logging decorator. And then we're also going to learn how to pass a logger to a decorator itself.
0:27
Alright, so let's talk about what a decorator is, just in case you don't know. A decorator is a function that takes another function as its argument. The decorator function will then extend the functionality of the function that it is decorating in some way. So in the case of logging,
0:44
you're going to want to create a decorator that can catch exceptions and log them if they occur in the decorated function. Other ways you might use a decorator would be to add authentication to a web page. Some people use them to create routes in Django or Flask. There's lots of different solutions for doing things with decorators.
you're going to want to create a decorator that can catch exceptions and log them if they occur in the decorated function. Other ways you might use a decorator would be to add authentication to a web page. Some people use them to create routes in Django or Flask. There's lots of different solutions for doing things with decorators.
Share this post