koaning / calmcode-feedback

A repo to collect issues with calmcode.io
16 stars 0 forks source link

Decorator with logger ? #174

Closed lcrmorin closed 1 year ago

lcrmorin commented 1 year ago

In the decorator videos, you show how to use a decorator for logging. However the logger is a custom logger... wouldn't this be possible (and better) with some standard logging library ? (https://docs.python.org/3/library/logging.html)

koaning commented 1 year ago

From a purist perspective: yes!

From an educational perspective: it's tricky! I'd need to assume folks are familiar with the logging module in order for them to learn about decorators. And that's a pretty big assumption to make.

That said, what you describe is something we implemented in scikit-lego for pandas pipelines: https://scikit-lego.netlify.app/pandas_pipeline.html#Logging-in-method-chaining