May-15-2017, 05:56 PM
Logging, metrics, and monitoring are also potential uses of decorators.
Logging, for example if the function throws an exception.
Metrics, such as the amount of time the calls take.
Monitoring / instrumentation generally speaking, e.g. a decorator that sends an email (rather than just log to a file) when a crucial function throws an exception, runs too slowly, or even returns unusual values.
Logging, for example if the function throws an exception.
Metrics, such as the amount of time the calls take.
Monitoring / instrumentation generally speaking, e.g. a decorator that sends an email (rather than just log to a file) when a crucial function throws an exception, runs too slowly, or even returns unusual values.