All the @logger
decoration does is automatically pass func
through logger
whenever func
is invoked. You can simulate this with:
logger(func)(2)
logger(func)
creates and returns a new function which writes out the log message and then calls func
. At this point you just have a function reference, which you can then invoke with the (2)
at the end.
You could also create a reference to that new function so you don't have to wrap it with logger()
each time.
f = logger(func)
f(2)
f(3)
f(4)