Creating a Logging Decorator

Sometimes you will want to create a log of what a function is doing. Most of the time, you will probably be doing your logging within the function itself. Occasionally you might want to do it at the function level to get an idea of the flow of the program or perhaps to fulfill some business rules, like auditing. Here’s a little decorator that we can use to record any function’s name and what it returns:

Get hands-on with 1200+ tech skills courses.