Fix issue #3130 by changing a wrong reference of scope

This fixes issue #3130

The scope of the `self` variable is wrong. I'm not entirely sure why, as I don't know any good logging mechanisms from extension-side, if anyone knows, I'll be glad to learn why.