Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Output the console to my web interface

  1. #1
    Join Date
    Oct 2005
    Posts
    307

    Default Output the console to my web interface

    I want the ability to show the console output in my web interfaces. Not to look at all the time, but something to glance at when needed. Is it stored anywhere? I could write all my normal console prints to a SQLITE table and look it up that way, but what things I don't print (errors)? If errors are not stored, could they be?

  2. #2
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    First thing that comes to mind is replacing the print function from the startup script;

    Code:
    local oldPrint = print
    print = function(...)
         -- do what you want with it, and also call oldPrint
    end
    dunno whether that will catch all output (error statements, or prints from C code for example)
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  3. #3
    Join Date
    Jun 2008
    Posts
    1,026

    Default

    capturing print will work BUT you must do this very carefully - if you have a scripting error in your print handler G will enter an endless loop.

  4. #4
    Join Date
    Oct 2005
    Posts
    307

    Default

    Just to test, I added a script below with scriptenable and fileloaded events. It doesn't fire soon enough, because the transports aren't using it.

    local oldprint = print
    function print(s)
    oldprint('USING NEW PRINT: ' .. s)
    end

    Where is can I place this to ensure it fires first?
    Last edited by shaun5; December 5th, 2011 at 01:34 PM.

  5. #5
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    I would say luascript\startup directory, but the test file there executes after several components load, so some stuff is fired before that.

    Then again; print is a global function, so replacing the global should mostly work, only other code that fires first and uses something like
    Code:
    local print = print
    because locals are considered faster, would not work then. And, you wouldn't be able to capture output from before that point in time where you replace print.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  6. #6
    Join Date
    Oct 2005
    Posts
    307

    Default

    The default script in the startup directory says that scripts in this directory should be at the end of the dependency list. In my mind, this is at the top of the dependency list...

  7. #7
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Quote Originally Posted by shaun5 View Post
    The default script in the startup directory says that scripts in this directory should be at the end of the dependency list. In my mind, this is at the top of the dependency list...
    you're right. Sorry had it the otherway around.

    In that case, some core functionality is implemented in Lua, so try adding some print statements at the start of some of those files; ComponentManager.lua, Transport.lua, etc. see which one prints first. Also a nice one would be the 'additions.lua' I think.

    Put your replacement function in a lua module, and add a require statement to the first one that executes you can find (or to all of them, wouldn't hurt). These core files should get you before the components loading and transport/communications starting. I guess that's what you need.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  8. #8
    Join Date
    Oct 2005
    Posts
    307

    Default

    Ron, can you tell me where the appropriate place to put this is? I don't want to maintain code in several places that is all aimed at the same thing....

  9. #9
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Well I would put it in the startup folder. It might not catch the very first of messages but close to that.
    Ron
    No support through PM

  10. #10
    Join Date
    Oct 2005
    Posts
    307

    Default

    Thanks Ron. For me this gets everything but the initial print showing the build. Programming this is a little challenging. One typo and Girder crashes immediately and you have to delete the code out of the startup file or fix the problem before it will restart. I ended up adding a script action to test the code. If the script causes Girder to crash, Girder will restart easily allowing you to fix the code...

    I'm not sure this is the best approach. I either need absolute error catching, or find another way...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •