sighalt / logdecorator

Move logging code out of your business logic with python decorators.
MIT License
73 stars 12 forks source link

Decorator access local variable inside a function #8

Closed ninn55 closed 4 years ago

ninn55 commented 4 years ago

Is it possiable to access local variable inside a function with log decorator ?

sighalt commented 4 years ago

Unfortunatelly not. It's only possible to access the given parameters, the return value and/or the raised exception. Also, I don't see how it might be possible to access local variables, without a considerable amount of hacking.

If you are in the need of logging something inside a function, the function is probably doing more than only one thing and it would be best to split it into multiple functions. This might then lead to the possibility to use the capabilities of logdecorator again.