Add support for reading the current line from squirrel

Looks like someone exposed this in a change request for squirrel 3.04 but I can’t find it referenced anywhere. This is useful for building logging frameworks that are actually useful in a production env.

http://forum.squirrel-lang.org/default.aspx?g=posts&m=5924

We actually added a different extension to Squirrel: it understands the output of the C preprocessor cpp, and reports line numbers against the original file, not the preprocessed version. (This is more useful when using our REST API for Squirrel then when using the online IDE, but people doing proper software engineering in Squirrel are probably mostly already using the API.) The C preprocessor also expands FILE and LINE.

Peter

So @peter, should server.log(__LINE__) work?

At least for me it just throws an error (with the line number I might add :))

2015-09-25 08:02:38 UTC-4 [Agent] ERROR: the index ‘LINE’ does not exist
2015-09-25 08:02:38 UTC-4 [Agent] ERROR: at main:415

For LINE and FILE to work, you’d need to use cpp yourself, and send the output of cpp to the Electric Imp build API: https://electricimp.com/docs/buildapi/

I admit I haven’t personally tried using the build API yet… I sort of should do really!

Peter

Hey guys,

I ended up writing this
https://forums.electricimp.com/discussion/4093/wrench-preprocessor-and-build-tools-for-the-electric-imp-platform#latest

Its not automatically supported but there is a file in wrench called logging.nut, It has a function that automatically includes a macro for getting LINE and FILE.