I don't see any problems with that. It's similar to this answer on SOthis answer on SO.
Just a couple minor things:
You don't need
argsin the emptylogfunctionYou should make the entire function anonymous and execute it immediately (as it's being done in the answer I linked to); I don't think there's any usecase for calling it otherwise
Don't forget
varin front of theivariable, otherwise it becomes global