akbooer / openLuup

a pure-Lua open-source emulation of the Vera Luup environment
Apache License 2.0
41 stars 19 forks source link

Can you add logging when compile_lua fails? #23

Closed imro2 closed 4 years ago

imro2 commented 4 years ago

I've been banging my head trying to figure out why my plugin was not loading in openLuup and could not find any logging. Basically when compile_lua fails during the plugin load, there is no logging what so ever. like the plugin did not exist. I am talking specifically about line 762 in loader.lua

      ok, code, error_msg = scheduler.context_switch (devNo,
          compile_lua, i.source_code, name)  -- load, compile, instantiate    
akbooer commented 4 years ago

Fair point! I'm not quite sure how this piece of code came in for such shoddy treatment.

It has been a design choice to make this module stand-alone (in that it should not depend on other openLuup modules) so it has no in-built error logging. It should, though, return an error message to be reported from a higher level.

Thanks, AK

akbooer commented 4 years ago

Having said this, it does actually write a dump file out to help with diagnostics, if DEBUG is enables for that module.

imro2 commented 4 years ago

I have noticed that it wrote the dump, but the dump does not include what went wrong. I took a code that worked when called through and requires statement and just changed it to be included through and it stopped working. I could not find out why, so I debugged openLuup and the error pointed me to “attempt to index global ‘arg’ (a nil value)”. Interesting that it works one way but not the other, but that is beside the point. It would be great if you were able to put the error message in the regular openLuup log, or at least include the error message in the dump and say that there was a problem loading the plugging and reference the dump.

thank you for looking into this and for the amazing work

akbooer commented 4 years ago

Development branch now has a fix for this issue. Can you confirm before I close?

imro2 commented 4 years ago

Works great. Took me a little bit to realize it was in the startup log, but it is there with all necessary info.

thank you!

akbooer commented 4 years ago

Excellent. Yes, the modules are loaded at startup, so that's when both compiler errors, and code that executes as the module is loaded, will appear. Errors from a running plugin with be in the regular log.

The fix was trivial, and tidied the code which was left over from a debugging development session and, unusually, never cleaned up.

Thanks for pointing this out.